bug: microcks login ignores the --config flag and always modifies default config
维护者通常 1 天内回复
评估
调研方向
先阅读 login.go 第 113-124 行附近,那里命令调用的是 config.DefaultLocalConfigPath(),而不是使用 globalClientOpts.ConfigPath。将其与 cmd.go 第 63 行附近以及 logout、context、start、stop 和 import 进行比较,后者已经遵循全局标志。修复方法是让 login 通过提供的配置路径进行读写;完成意味着 microcks login http://localhost:8080 --config ./test-config.yaml 会更新该文件,并保持默认配置不变。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
When authenticating using the microcks login command, the global --config <path> flag is silently ignored. Even when a custom configuration file path is explicitly provided, microcks login continues to read and write authentication tokens, users, and contexts directly to the default path (~/.config/microcks/config).
This breaks multi-profile setups, CI/CD pipeline isolation (where jobs maintain ephemeral configuration files in dedicated directories), and prevents tests from running in isolated temporary directories.
Expected behavior
Passing --config <path> to microcks login should load and persist configuration, user tokens, server definitions, and contexts into the specified path, matching the behavior of microcks logout, microcks context, microcks start, microcks stop, and microcks import.
Actual behavior
microcks login ignores the provided --config argument and writes the login state to ~/.config/microcks/config. The specified custom configuration file remains untouched.
How to Reproduce?
-
Specify a path for an isolated custom configuration file (e.g.,
./test-config.yaml). -
Run the login command with the custom configuration file:
microcks login http://localhost:8080 --config ./test-config.yaml -
Check
./test-config.yamland observe that the file was not created or modified. -
Check
~/.config/microcks/configand observe that the default configuration file was updated with the context and server information.
Microcks version or git rev
1.0.3 / master (commit 5cef506)
Install method (docker-compose, helm chart, operator, docker-desktop extension,...)
Built from source (go build)
Additional information
Root cause
In cmd.go:63, the persistent --config flag is registered and bound to clientOpts.ConfigPath, then passed to NewLoginCommand(&clientOpts):
command.PersistentFlags().StringVar(
&clientOpts.ConfigPath,
"config",
defaultLocalConfigPath,
"Path to Microcks config",
)
command.AddCommand(NewLoginCommand(&clientOpts))
However, in login.go:113-124, the command hardcodes a call to config.DefaultLocalConfigPath() instead of reading globalClientOpts.ConfigPath:
configFile, err := config.DefaultLocalConfigPath()
if err != nil {
return err
}
localConfig, err := config.ReadLocalConfig(configFile)
// ...
if err := config.WriteLocalConfig(*localConfig, configFile); err != nil {
return err
}
Every other command (start, stop, context, logout, import, and service) correctly uses globalClientOpts.ConfigPath.
Changing the hardcoded path assignment to configFile := globalClientOpts.ConfigPath should restore consistency across the CLI and ensure that microcks login respects the global --config flag.
- 主要语言
- Go
- 星标
- 59
- 派生
- 74
- 平均合并
- 5 天 17 小时
- 30 天内合并 PR
- 22
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microcks/microcks-cli 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
microcks/microcks-cli#601 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
microcks/microcks-cli#598 ·
维护者通常 1 天内回复
-
Wrong link to test results可能已有人在做 @SajanBisht 于 3 天前认领。 未关闭component/cli keep-open kind/bug
难度 2/5 1-3 小时 新手友好度 62/100
microcks/microcks-cli#589 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Default configuration path falls back to the current directory when the home directory cannot be determined可能已有人在做 @Sarthak-Shreshtha01 于 16 天前认领。 未关闭component/cli kind/bug
难度 2/5 1-3 小时 新手友好度 76/100
microcks/microcks-cli#583 · 5 条评论 ·
维护者通常 1 天内回复
-
bug: YAML parse error in config is silently swallowed, login overwrites all other contexts可能已有人在做 @Sarthak-Shreshtha01 于 22 天前认领。 未关闭component/cli kind/bug
难度 2/5 1-3 小时 新手友好度 76/100
microcks/microcks-cli#572 · 6 条评论 ·
维护者通常 1 天内回复
查看 microcks/microcks-cli 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
schema-drift
难度 2/5 1-3 小时 新手友好度 72/100
stefanhoth/paperless-ngx-cli#61 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100
slavakurilyak/awesome-ai-agents#888 ·
维护者通常 1 天内回复
-
enhancement nav-pilot
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
kind/enhancement
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复