-
Notifications
You must be signed in to change notification settings - Fork 6.4k
fix: config loader accepts multiple parameters with the same key #24938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix: config loader accepts multiple parameters with the same key #24938
Conversation
❗ Preview Environment deployment failed on BunnyshellSee: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
} | ||
// 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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep returning "true" because some caller expects it
https://github.com/shota3506/argo-cd/blob/95b191d349448b56ccd258ca9e44f41352e0b0af/util/localconfig/localconfig.go#L315-L319
d6ce57c
to
b23e575
Compare
Codecov Report❌ Patch coverage is
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. |
Signed-off-by: shota3506 <[email protected]>
b23e575
to
1d53395
Compare
util/config/env.go
Outdated
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{} | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Signed-off-by: shota3506 <[email protected]>
41cee0e
to
9f8d51e
Compare
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
tomap[string][]string
to support multiple values per key.GetStringSliceFlag
properly handle multiple flag occurrences, whileGetFlag
,GetIntFlag
keeps returning the last specified value.Checklist: