Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The argocd CLI lets
ARGOCD_SERVERandARGOCD_AUTH_TOKENoverride the server and token of whichever context is selected. The plugin provisioned both for every command, so switching contexts withargocd contextor passing--argocd-contexthad no effect: every command went to the server stored in the 1Password item, and--server <other>sent the stored token to whichever server the user named.When the item has an Address, the provisioner now resolves the server argocd is about to use, in argocd's own order (
--server, thenARGOCD_SERVER, then the context named by--argocd-context, thencurrent-contextfrom the config file), and only provisions when that server matches the Address. Otherwise it provisions nothing and argocd uses its own config. If the target cannot be determined, the token is provisioned as before.loginandreloginno longer require authentication, since both connect to a server the plugin cannot see and obtain their own token.Type of change
Related Issue(s)
How To Test
Unit tests, including regression tests for the reported behaviour:
go test ./plugins/argocd/ -vTestAddressAwareProvisionercovers the current context matching and not matching the item's Address,--argocd-contextand--serverpointing at the item's server and at another one, an exportedARGOCD_SERVER, the legacy~/.argocdconfig location, and address normalisation.TestArgocdCLINeedsAuthchecks thatloginandreloginskip authentication.End to end with the CLI, using a 1Password item whose Address is your production server and an argocd config with a second, local context:
Before the change this returned the production user regardless of the selected context. It should now return the local one.
argocd account get-user-info --argocd-context <production-context>should still authenticate with the 1Password token.Changelog
The Argo CD plugin now respects the selected context: credentials from 1Password are only provided when argocd is targeting the server stored in the item's Address, so switching contexts and
--argocd-context,--serverwork as they do without the plugin.