Add text output mode for auth token and auth env#4725
Add text output mode for auth token and auth env#4725simonfaltum wants to merge 7 commits intomainfrom
Conversation
Both commands now respect --output text when explicitly set: - auth token --output text: outputs just the access token string - auth env --output text: outputs KEY=VALUE lines JSON remains the default for backward compatibility. Co-authored-by: Isaac
|
Commit: a6000ec
38 interesting tests: 11 MISS, 7 SKIP, 6 FAIL, 6 flaky, 6 RECOVERED, 1 KNOWN, 1 PANIC
Top 50 slowest tests (at least 2 minutes):
|
Co-authored-by: Isaac
shreyas-goenka
left a comment
There was a problem hiding this comment.
Note: This review was posted by Claude (AI assistant). Shreyas will do a separate, more thorough review pass.
Priority: MEDIUM — Env var inconsistency needs a decision
HIGH: DATABRICKS_OUTPUT_FORMAT env var silently ignored
Both auth token and auth env commands use cmd.Flag("output").Changed to detect text mode, which means the DATABRICKS_OUTPUT_FORMAT=text env var is ignored. This is inconsistent with the rest of the CLI where the env var is a first-class way to set output format. The guard exists because these commands have an inverted default (JSON by default, unlike other commands), so without it the default behavior would break. A decision is needed on whether the env var should be honored here.
MEDIUM: Shell quoting not fully .env-file compatible
The quoteEnvValue function uses POSIX shell single-quote escaping ('\''), but the PR description claims ".env loader" compatibility. Most .env parsers (Docker, python-dotenv) use different quoting rules. Only eval usage is truly compatible.
LOW: Doc comment typo
quoteEnvValue doc references '\" but code does '\''.
What looks good
- Backward compatibility preserved (JSON remains default)
collectEnvVarsextraction reduces duplication- Clean text output formatting
The comment referenced the '\" escape sequence, but the code actually uses the POSIX '\'' sequence (end-quote, backslash-escaped literal single quote, re-open quote).
…al characters Values containing \n or \r were emitted unquoted, producing raw multi-line shell output instead of a single safe KEY=VALUE pair. Add both characters to shellQuotedSpecialChars so they trigger single-quoting.
Why
databricks auth tokenanddatabricks auth envalways output JSON, ignoring the--outputflag. Users who want to pipe the token string or source env vars have to parse JSON first.Changes
Before: Both commands always output JSON regardless of the
--outputflag.Now: Both commands respect
--output textwhen explicitly set:auth token --output text: outputs just the access token string, suitable for pipingauth env --output text: outputs KEY=VALUE lines, compatible with .env loaders and evalJSON remains the default (backward compatible). Text mode activates only when the user explicitly passes
--output text.Test plan
make checkspasses