feat: support JFROG_CLI_URL/ACCESS_TOKEN/USER/PASSWORD env fallbacks (#3490)#3531
Open
mvanhorn wants to merge 1 commit into
Open
feat: support JFROG_CLI_URL/ACCESS_TOKEN/USER/PASSWORD env fallbacks (#3490)#3531mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
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.
Summary
Adds environment-variable fallbacks for the core connection details in
CreateServerDetailsFromFlags:JFROG_CLI_URL->--urlJFROG_CLI_ACCESS_TOKEN->--access-tokenJFROG_CLI_USER->--userJFROG_CLI_PASSWORD->--passwordA flag value, when supplied, always wins over the corresponding environment variable; the environment variable is used only when the flag (and, for secrets, the
--*-stdinpath) is empty. When no flag and no env var are set, behavior is unchanged. This mirrors the existingJFROG_CLI_SERVER_IDenv fallback that already lives in this same function.The new variables are documented in
docs/common/env.goand registered inGetGlobalEnvVars()so they appear injf options/help output.Why this matters
Issue #3490 asks for an env-only path to supply connection details so that pipelines and Docker-based CI can avoid repeating
--url/--access-tokenon everyjfinvocation (and avoid putting credentials on the command line). The repo already has the exact precedent for this:ServerIdfalls back toos.Getenv(coreutils.ServerID)(JFROG_CLI_SERVER_ID) insideCreateServerDetailsFromFlags. This change extends that established pattern to the remaining connection fields, keeping the implementation small and consistent.Behavior notes (intentional, for parity with the flags):
JFROG_CLI_URLis treated exactly like--url: per-service URLs (Artifactory/Xray/Distribution) are derived from it by the existing domain switch increateServerDetailsFromFlags, so setting it to a platform base behaves identically to passing--url. No/artifactoryauto-append is added.CreateServerDetailsWithConfigOffer(credentialsChanged), i.e. command-supplied details and stored server config remain mutually exclusive. This is the same exclusivity already enforced for--access-token/--user/--password.Testing
TestCreateServerDetailsFromFlagsEnvFallbackinutils/cliutils/utils_test.go, a table-driven test covering: env fallback for url/user/password/access-token, flag-wins-over-env precedence, trailing-slash handling on the URL, and the no-flag/no-env case (empty fields, no regression).gofmt -lclean on all changed files.go vet ./utils/...clean.go build ./...succeeds.go test ./utils/cliutils/...passes (including the new test).Fixes #3490
AI was used for assistance.