You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generalize CLI token source into progressive command list
Replace the three explicit command fields (forceCmd, profileCmd, hostCmd)
with a []cliCommand list and an activeCommandIndex. Feature flags are
defined statically in cliFeatureFlags and stripped progressively to
build commands for older CLI versions.
Token() now iterates from activeCommandIndex, falling back on unknown
flag errors and caching the working command index for subsequent calls.
Adding future flags (e.g. --scopes) requires only a one-line addition
to the cliFeatureFlags slice.
Signed-off-by: Mihai Mitrea <mihai.mitrea@databricks.com>
Copy file name to clipboardExpand all lines: NEXT_CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@
24
24
### Internal Changes
25
25
26
26
* Pass `--force-refresh` to Databricks CLI `auth token` command to bypass the CLI's internal token cache.
27
+
* Generalize CLI token source into a progressive command list for forward-compatible flag support.
27
28
* Use resolved host type from host metadata in `HostType()` method, falling back to URL pattern matching when metadata is unavailable.
28
29
* Normalize internal token sources on `auth.TokenSource` for proper context propagation ([#1577](https://github.com/databricks/databricks-sdk-go/pull/1577)).
29
30
* Fix `TestAzureGithubOIDCCredentials` hang caused by missing `HTTPTransport` stub: `EnsureResolved` now calls `resolveHostMetadata`, which makes a real network request when no transport is set ([#1550](https://github.com/databricks/databricks-sdk-go/pull/1550)).
warningMessage: "Databricks CLI does not support --force-refresh flag. The CLI's token cache may provide stale tokens. Please upgrade your CLI to the latest version.",
warningMessage: "Databricks CLI does not support --force-refresh flag. The CLI's token cache may provide stale tokens. Please upgrade your CLI to the latest version.",
logger.Warnf(ctx, "Databricks CLI does not support --force-refresh flag. The CLI's token cache may provide stale tokens. Please upgrade your CLI to the latest version.")
115
+
// If the working command has already been identified, call it directly.
116
+
// Otherwise, probe each command in order to find one that works.
117
+
ifidx:=int(c.activeCommandIndex.Load()); idx>=0 {
118
+
returnc.execCliCommand(ctx, c.commands[idx].args)
107
119
}
120
+
returnc.probeAndExec(ctx)
121
+
}
108
122
109
-
ifc.profileCmd!=nil {
110
-
tok, err:=c.execCliCommand(ctx, c.profileCmd)
123
+
// probeAndExec walks the command list from most-featured to simplest, looking
124
+
// for a CLI command that succeeds. When a command fails with "unknown flag" for
125
+
// one of its [cliCommand.usedFlags], it logs a warning and tries the next. Any
126
+
// other error stops probing immediately and is returned to the caller.
127
+
// On success, [activeCommandIndex] is stored so future calls skip probing.
0 commit comments