fix: relogin command ignores --argocd-context flag#26796
fix: relogin command ignores --argocd-context flag#26796AlJohri wants to merge 1 commit intoargoproj:masterfrom
Conversation
🔴 Preview Environment stopped on BunnyshellSee: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
The relogin command hardcoded `localCfg.CurrentContext` instead of using `clientOpts.Context` (the --argocd-context flag value). This caused it to connect to the wrong server and update the wrong context entry. Signed-off-by: Al Johri <al.johri@gmail.com>
bd0883c to
98b50b4
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #26796 +/- ##
=======================================
Coverage 62.89% 62.89%
=======================================
Files 414 414
Lines 56143 56143
=======================================
+ Hits 35310 35313 +3
+ Misses 17480 17476 -4
- Partials 3353 3354 +1 ☔ View full report in Codecov by Sentry. |
choejwoo
left a comment
There was a problem hiding this comment.
Generally LGTM.
Could we add a regression test covering argocd relogin --argocd-context <other-context> so we verify it updates the selected context rather than current-context?
ppapapetrou76
left a comment
There was a problem hiding this comment.
I agree with @choejwoo - let's add a quick test ( I would expect that the test would fail before the change and succeeds after the change )
dudinea
left a comment
There was a problem hiding this comment.
It would be great if you added an example using the --argocd-context flag to the usage string, so people know that this option an be used with this command.
Summary
argocd relogin --argocd-context <name>uses the current context's server instead of the server from the specified--argocd-context, causing credentials to be sent to the wrong ArgoCD serverrelogin.gohardcodeslocalCfg.CurrentContextinstead of usingclientOpts.Context(the--argocd-contextflag value), unlike every other command which correctly passesclientOpts.ContexttoResolveContext()clientOpts.Contextfor context resolution (which already falls back toCurrentContextwhen empty), and useconfigCtx.Namefor the upsert and status messageTest plan
argocd context cluster-a)argocd relogin --argocd-context cluster-b --password <cluster-b-password>Context 'cluster-b' updated(previously failed with "Invalid username or password" and would have printedContext 'cluster-a' updated)argocd reloginwithout--argocd-contextstill works (falls back to current context viaResolveContext(""))