From 875f56809cf54e1a65a9f62f9a5e851b2a03ef80 Mon Sep 17 00:00:00 2001 From: ansita20 Date: Sat, 9 May 2026 03:13:25 +0530 Subject: [PATCH 1/6] fix:command-spelling-error Signed-off-by: ansita20 --- cmd/cmd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index 16df6b9a..33b6733c 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 From 95a992ec0a51ba9306abcf57a7d211cacc6925fb Mon Sep 17 00:00:00 2001 From: ansita20 Date: Sat, 9 May 2026 03:16:06 +0530 Subject: [PATCH 2/6] fix: NewWatchManger typo and file path normalization Signed-off-by: ansita20 --- cmd/import.go | 11 ++++++----- pkg/watcher/watchManager.go | 2 +- watcher/main.go | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/import.go b/cmd/import.go index c1a74c4c..c3073576 100644 --- a/cmd/import.go +++ b/cmd/import.go @@ -131,6 +131,11 @@ func NewImportCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command } } + // Normalize file path to match the watcher fsnotify events format. + if strings.HasPrefix(f, "./") { + f = strings.TrimPrefix(f, "./") + } + // Try uploading this artifact. msg, err := mc.UploadArtifact(f, mainArtifact) if err != nil { @@ -154,10 +159,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{ @@ -177,7 +178,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/pkg/watcher/watchManager.go b/pkg/watcher/watchManager.go index 5b0f717a..10a06fde 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 54f06cd1..b1959dea 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...") From af23f9fd9af44e441501638fa2e5bda782d8893e Mon Sep 17 00:00:00 2001 From: ansita20 Date: Sat, 23 May 2026 11:15:48 +0300 Subject: [PATCH 3/6] tests: use t.TempDir() in TestDeleteContext; fix entrypoint typo in main.go Signed-off-by: ansita20 --- cmd/context_test.go | 5 +++-- main.go | 2 +- package-lock.json | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 package-lock.json diff --git a/cmd/context_test.go b/cmd/context_test.go index 8de7935a..dddd1c38 100644 --- a/cmd/context_test.go +++ b/cmd/context_test.go @@ -2,6 +2,7 @@ package cmd import ( "os" + "path/filepath" "testing" "github.com/microcks/microcks-cli/pkg/config" @@ -36,9 +37,9 @@ users: auth-token: "" refresh-token: ""` -const testConfigFilePath = "./testdata/local.config" - func TestDeleteContext(t *testing.T) { + testConfigFilePath := filepath.Join(t.TempDir(), "local.config") + //write the test config file err := os.WriteFile(testConfigFilePath, []byte(testConfig), os.ModePerm) require.NoError(t, err) diff --git a/main.go b/main.go index b595a373..860c31c6 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/package-lock.json b/package-lock.json new file mode 100644 index 00000000..91433845 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "microcks-cli", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} From f70fb9da2d2a7a2688014d7afe7c6b779c00a701 Mon Sep 17 00:00:00 2001 From: ansita20 Date: Sat, 23 May 2026 11:32:08 +0300 Subject: [PATCH 4/6] tests: write config with 0600 in TestDeleteContext to avoid permissive file mode Signed-off-by: ansita20 --- cmd/context_test.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cmd/context_test.go b/cmd/context_test.go index dddd1c38..44de6721 100644 --- a/cmd/context_test.go +++ b/cmd/context_test.go @@ -40,12 +40,9 @@ users: func TestDeleteContext(t *testing.T) { testConfigFilePath := filepath.Join(t.TempDir(), "local.config") - //write the test config file - err := os.WriteFile(testConfigFilePath, []byte(testConfig), os.ModePerm) + // write the test config file with restrictive permissions (owner read/write) + err := os.WriteFile(testConfigFilePath, []byte(testConfig), 0o600) require.NoError(t, err) - - err = os.Chmod(testConfigFilePath, 0o600) - require.NoError(t, err, "Could not change the file permission to 0600 %v", err) localCfg, err := config.ReadLocalConfig(testConfigFilePath) require.NoError(t, err) assert.Equal(t, "http://localhost:8083", localCfg.CurrentContext) From f9d8802c9cd796b677c18d85590f47c1c65ccf32 Mon Sep 17 00:00:00 2001 From: ansita20 Date: Sat, 23 May 2026 16:51:53 +0300 Subject: [PATCH 5/6] revert: drop duplicate context test changes from this branch Signed-off-by: ansita20 --- cmd/context_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/context_test.go b/cmd/context_test.go index 44de6721..cc42a254 100644 --- a/cmd/context_test.go +++ b/cmd/context_test.go @@ -2,7 +2,6 @@ package cmd import ( "os" - "path/filepath" "testing" "github.com/microcks/microcks-cli/pkg/config" @@ -38,11 +37,14 @@ users: refresh-token: ""` func TestDeleteContext(t *testing.T) { - testConfigFilePath := filepath.Join(t.TempDir(), "local.config") + testConfigFilePath := "./testdata/local.config" - // write the test config file with restrictive permissions (owner read/write) - err := os.WriteFile(testConfigFilePath, []byte(testConfig), 0o600) + //write the test config file + err := os.WriteFile(testConfigFilePath, []byte(testConfig), os.ModePerm) require.NoError(t, err) + + err = os.Chmod(testConfigFilePath, 0o600) + require.NoError(t, err, "Could not change the file permission to 0600 %v", err) localCfg, err := config.ReadLocalConfig(testConfigFilePath) require.NoError(t, err) assert.Equal(t, "http://localhost:8083", localCfg.CurrentContext) From cb5cf92b3098ca5d2523767342f254457069c138 Mon Sep 17 00:00:00 2001 From: ansita20 Date: Sat, 23 May 2026 16:54:17 +0300 Subject: [PATCH 6/6] revert: drop duplicate context test changes from this branch Signed-off-by: ansita20 --- cmd/context_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/context_test.go b/cmd/context_test.go index cc42a254..8de7935a 100644 --- a/cmd/context_test.go +++ b/cmd/context_test.go @@ -36,9 +36,9 @@ users: auth-token: "" refresh-token: ""` -func TestDeleteContext(t *testing.T) { - testConfigFilePath := "./testdata/local.config" +const testConfigFilePath = "./testdata/local.config" +func TestDeleteContext(t *testing.T) { //write the test config file err := os.WriteFile(testConfigFilePath, []byte(testConfig), os.ModePerm) require.NoError(t, err)