Skip to content

Commit

Permalink
fix: strip some invalid charts from file names
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Falk Nielsen committed Jun 19, 2024
1 parent 24e62d7 commit dafc6cd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/inventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package inventory

import (
"fmt"
"regexp"
"strings"
"time"

Expand All @@ -20,6 +21,7 @@ type InventorySync struct {
systray *tray.SysTray
periodicTicker *time.Ticker
LastSync time.Time
stripRe *regexp.Regexp
}

func New(cfg *config.Config, nb *netbox.NetBox, scrt *securecrt.SecureCRT, systray *tray.SysTray) *InventorySync {
Expand All @@ -29,6 +31,7 @@ func New(cfg *config.Config, nb *netbox.NetBox, scrt *securecrt.SecureCRT, systr
scrt: scrt,
systray: systray,
periodicTicker: time.NewTicker(time.Minute * time.Duration(*cfg.PeriodicSyncInterval)),
stripRe: regexp.MustCompile(`[\\/\?]`),
}

return &inv
Expand Down Expand Up @@ -94,6 +97,7 @@ func (i *InventorySync) writeSession(sessionType string, site *models.Site, tena
templateVariables,
)

name = i.stripRe.ReplaceAllString(name, "")
sessionPath := templater.ApplyTemplate(fmt.Sprintf("%s/%s/%s.ini", i.cfg.RootPath, template, name), templateVariables)
err := i.scrt.WriteSession(sessionPath, sessionData)
if err != nil {
Expand Down

0 comments on commit dafc6cd

Please sign in to comment.