feat: support JFROG_CLI_URL/ACCESS_TOKEN/USER/PASSWORD env fallbacks (#3490) - #3531
feat: support JFROG_CLI_URL/ACCESS_TOKEN/USER/PASSWORD env fallbacks (#3490)#3531mvanhorn wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
Is there any movement on this merge? It would be a very welcoming change |
|
Thanks for the bump. Nothing is blocked on my side, so here is where it stands in case a maintainer sees this. The change is complete and the CLA is signed. The only red check is So the unblocking step is a maintainer approving or re-running the workflow on this PR. If the scan then finds something real I will fix it the same day. If the feature itself needs a decision rather than a scan, happy to have that conversation instead. #3490 asked for |
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.