Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

bug: microcks login ignores the --config flag and always modifies default config

未关闭 适合新手
#594 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@aryarathoree 已经在做这个了。

开始于 2026年10月27日。

  • #599 来自 @aryarathoree —— 未关闭

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
88/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
cli

调研方向

先阅读 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?
  1. Specify a path for an isolated custom configuration file (e.g., ./test-config.yaml).

  2. Run the login command with the custom configuration file:

    microcks login http://localhost:8080 --config ./test-config.yaml
    
  3. Check ./test-config.yaml and observe that the file was not created or modified.

  4. Check ~/.config/microcks/config and 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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microcks/microcks-cli 的其他 Issue

查看 microcks/microcks-cli 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。