Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#594 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@aryarathoree đang làm issue này rồi.

Từ ngày 27/10/2026.

  • #599 của @aryarathoree — đang mở

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
88/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu bằng việc đọc login.go quanh các dòng 113-124, nơi lệnh gọi config.DefaultLocalConfigPath() thay vì dùng globalClientOpts.ConfigPath. Hãy so sánh điều đó với cmd.go quanh dòng 63 và với logout, context, start, stop và import, những lệnh đã tuân theo cờ toàn cục. Bản sửa là làm cho login đọc và ghi qua đường dẫn cấu hình được cung cấp; hoàn tất nghĩa là microcks login http://localhost:8080 --config ./test-config.yaml cập nhật tệp đó và để nguyên cấu hình mặc định.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Go
Star
59
Fork
74
Merge trung bình
5 ngày 17 giờ
Pull request đã merge (30 ngày)
22

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microcks/microcks-cli

Tất cả issue của microcks/microcks-cli

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.