Skip to content

Conversation

shota3506
Copy link

@shota3506 shota3506 commented Oct 12, 2025

This PR resolves #24065.

This PR fixes an issue where the ARGOCD_OPTS environment variable config loader could not accept multiple parameters with the same key.
Setting ARGOCD_OPTS would be identically to setting the CLI options.

I modified the internal flags storage from map[string]string to map[string][]string to support multiple values per key.
GetStringSliceFlag properly handle multiple flag occurrences, while GetFlag, GetIntFlag keeps returning the last specified value.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Title of the PR
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

@shota3506 shota3506 requested a review from a team as a code owner October 12, 2025 02:52
Copy link

bunnyshell bot commented Oct 12, 2025

❗ Preview Environment deployment failed on Bunnyshell

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

}
// pkg shellquota doesn't recognize `=` so that the opts in format `foo=bar` could not work.
// issue ref: https://github.com/argoproj/argo-cd/issues/6822
for k, v := range flags {
Copy link
Author

Choose a reason for hiding this comment

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

avoid map iteration so that the parsed flag map becomes deterministic

}
if len(val) == 0 {
// emtpy slice means bool flag.
return "true", true
Copy link
Author

Choose a reason for hiding this comment

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

Copy link

codecov bot commented Oct 12, 2025

Codecov Report

❌ Patch coverage is 82.92683% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.80%. Comparing base (95b191d) to head (9f8d51e).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
util/config/env.go 82.92% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #24938   +/-   ##
=======================================
  Coverage   60.79%   60.80%           
=======================================
  Files         351      351           
  Lines       60439    60455   +16     
=======================================
+ Hits        36745    36760   +15     
- Misses      20772    20773    +1     
  Partials     2922     2922           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shota3506 shota3506 force-pushed the argocdopts-accepts-multiple-parameters branch from b23e575 to 1d53395 Compare October 12, 2025 03:37
Comment on lines 31 to 45
setKey := func(key string) {
// pkg shellquota doesn't recognize `=` so that the opts in format `foo=bar` could not work.
// issue ref: https://github.com/argoproj/argo-cd/issues/6822
if strings.Contains(key, "=") {
kv := strings.SplitN(key, "=", 2)
actualKey, actualValue := kv[0], kv[1]
flags[actualKey] = append(flags[actualKey], actualValue)
} else {
if _, ok := flags[key]; !ok {
// empty slice means bool flag.
flags[key] = []string{}
}
}
}

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer keeping it as a separate function and adding tests for it too.

Copy link
Author

@shota3506 shota3506 Oct 13, 2025

Choose a reason for hiding this comment

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

@nitishfy I added processKey method and write some tests for it.

@shota3506 shota3506 force-pushed the argocdopts-accepts-multiple-parameters branch from 41cee0e to 9f8d51e Compare October 13, 2025 13:51
@shota3506 shota3506 requested a review from nitishfy October 13, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ARGOCD_OPTS does not accept --header parameter multiple times

2 participants