diff --git a/cmd/cmd.go b/cmd/cmd.go index 16df6b9..5500ef5 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -22,7 +22,7 @@ import ( "github.com/spf13/cobra" ) -func NewCommad() *cobra.Command { +func NewCommand() *cobra.Command { var clientOpts connectors.ClientOptions @@ -62,4 +62,4 @@ func NewCommad() *cobra.Command { command.MarkFlagsRequiredTogether("keycloakClientId", "keycloakClientSecret") return command -} +} \ No newline at end of file diff --git a/cmd/import.go b/cmd/import.go index c1a74c4..e8ae683 100644 --- a/cmd/import.go +++ b/cmd/import.go @@ -131,6 +131,9 @@ func NewImportCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command } } + // Normalize file path to keep upload and watch config paths consistent. + f = strings.TrimPrefix(f, "./") + // Try uploading this artifact. msg, err := mc.UploadArtifact(f, mainArtifact) if err != nil { @@ -154,11 +157,6 @@ func NewImportCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command watchCfg = &config.WatchConfig{} } - // Normalize file path to match the watcher fsnotify events format. - if strings.HasPrefix(f, "./") { - f = strings.TrimPrefix(f, "./") - } - // Upsert entry. watchCfg.UpsertEntry(config.WatchEntry{ FilePath: f, @@ -177,7 +175,7 @@ func NewImportCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command watchFile, err := config.DefaultLocalWatchPath() errors.CheckError(err) - wm, err := watcher.NewWatchManger(watchFile) + wm, err := watcher.NewWatchManager(watchFile) errors.CheckError(err) fmt.Println("Watch mode enabled - microcks-watcher started...") diff --git a/main.go b/main.go index b595a37..860c31c 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,7 @@ import ( ) func main() { - command := cmd.NewCommad() + command := cmd.NewCommand() if err := command.Execute(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) diff --git a/pkg/watcher/executor.go b/pkg/watcher/executor.go index 3347fc6..3c42fca 100644 --- a/pkg/watcher/executor.go +++ b/pkg/watcher/executor.go @@ -12,7 +12,8 @@ func TriggerImport(entry config.WatchEntry) { // Retrieve config to get client options. cfgPath, err := config.DefaultLocalConfigPath() if err != nil { - fmt.Errorf("Error while loading config: %s", err.Error()) + fmt.Printf("Error while loading config: %s\n", err.Error()) + return } fmt.Println("[INFO] Re-importing changed file: " + entry.FilePath) diff --git a/pkg/watcher/watchManager.go b/pkg/watcher/watchManager.go index 5b0f717..10a06fd 100644 --- a/pkg/watcher/watchManager.go +++ b/pkg/watcher/watchManager.go @@ -17,7 +17,7 @@ type WatchManager struct { lock sync.Mutex } -func NewWatchManger(configPath string) (*WatchManager, error) { +func NewWatchManager(configPath string) (*WatchManager, error) { fw, err := fsnotify.NewWatcher() if err != nil { return nil, err diff --git a/watcher/main.go b/watcher/main.go index 54f06cd..b1959de 100644 --- a/watcher/main.go +++ b/watcher/main.go @@ -12,7 +12,7 @@ func main() { watchFile, err := config.DefaultLocalWatchPath() errors.CheckError(err) - wm, err := watcher.NewWatchManger(watchFile) + wm, err := watcher.NewWatchManager(watchFile) errors.CheckError(err) fmt.Println("[INFO] microcks-watcher started...")