Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/spf13/cobra"
)

Comment thread
Ansita20 marked this conversation as resolved.
func NewCommad() *cobra.Command {
func NewCommand() *cobra.Command {

var clientOpts connectors.ClientOptions

Expand Down Expand Up @@ -62,4 +62,4 @@ func NewCommad() *cobra.Command {
command.MarkFlagsRequiredTogether("keycloakClientId", "keycloakClientSecret")

return command
}
}
10 changes: 4 additions & 6 deletions cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -154,11 +157,6 @@ func NewImportCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command
watchCfg = &config.WatchConfig{}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the renames @Ansita20, those parts look good.

seems you deleted the normalization block entirely:

-if strings.HasPrefix(f, "./") {
-    f = strings.TrimPrefix(f, "./")
-}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes sir I just saw that...there was some issues with the code so I had to remove it but forgot to fix and add it agian.
I have made the changes can you please check once again.
I am really sorry for the errors.

// 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,
Expand All @@ -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...")
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion pkg/watcher/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/watcher/watchManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion watcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
Expand Down