Skip to content

fix: make argocd login respect the context name #22643

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

Closed
wants to merge 1 commit into from

Conversation

cardoe
Copy link
Contributor

@cardoe cardoe commented Apr 11, 2025

The argocd CLI login command does not respect the --argocd-context flag to name the context and always uses the name of the server. This makes it respect the flag and use the supplied context name. Removed check against empty ctxName which is done higher up already.

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 Toolchain Guide
  • 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).

@cardoe cardoe requested a review from a team as a code owner April 11, 2025 20:59
Copy link

bunnyshell bot commented Apr 11, 2025

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@cardoe
Copy link
Contributor Author

cardoe commented Apr 11, 2025

relates to #19867 which will hopefully make this all the more complete

@cardoe
Copy link
Contributor Author

cardoe commented Apr 12, 2025

The test failed performing a git operation unrelated to my change.

The argocd CLI login command does not respect the --argocd-context flag
to name the context and always uses the name of the server. This makes
it respect the flag and use the supplied context name. Removed check
against empty ctxName which is done higher up already.

Signed-off-by: Doug Goldstein <[email protected]>
@cardoe cardoe force-pushed the respect-argocd-context branch from c3cc140 to e6d0957 Compare April 12, 2025 14:15
Copy link

codecov bot commented Apr 12, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 56.05%. Comparing base (127eef9) to head (e6d0957).
Report is 18 commits behind head on master.

Files with missing lines Patch % Lines
cmd/argocd/commands/login.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #22643      +/-   ##
==========================================
- Coverage   56.06%   56.05%   -0.01%     
==========================================
  Files         343      343              
  Lines       57536    57535       -1     
==========================================
- Hits        32257    32254       -3     
- Misses      22634    22641       +7     
+ Partials     2645     2640       -5     

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

@cardoe
Copy link
Contributor Author

cardoe commented Apr 12, 2025

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

The entire function where I made the change is uncovered.

@@ -112,6 +112,8 @@ argocd login cd.argoproj.io --core`,
ServerName: globalClientOpts.ServerName,
}

ctxName = globalClientOpts.Context
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ctxName = globalClientOpts.Context
ctxName = globalClientOpts.Context

why is this required? Shouldn't we get the ctxName value automatically from the flag itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That global option is the flag where it's being read from. If it's not supplied then it's created.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nitishfy So today if you run argocd login argocd.my.host --sso --argocd-context my-argocd the context that gets created is called argocd.my.host and the option is ignored. The code path today sets the ctxName variable equal to the server name if its unset (which is always is). Then it performs some additional transformations on the ctxName variable. What I did was just default the ctxName to the command line flag in this change.

Copy link
Member

Choose a reason for hiding this comment

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

for setting the ctx, you can simply use the --name flag

Copy link
Contributor Author

Choose a reason for hiding this comment

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

uhhh derp on my part @nitishfy.

@cardoe cardoe closed this Apr 17, 2025
@cardoe cardoe deleted the respect-argocd-context branch April 17, 2025 22:07
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.

2 participants