Move cloud filtering from individual strategies to DefaultCredentials#1505
Merged
hectorcast-db merged 2 commits intomainfrom Mar 3, 2026
Merged
Move cloud filtering from individual strategies to DefaultCredentials#1505hectorcast-db merged 2 commits intomainfrom
hectorcast-db merged 2 commits intomainfrom
Conversation
Previously each Azure/GCP strategy would return nil on a non-matching host cloud (e.g. AzureCliCredentials returned nil on a GCP host). This meant that explicitly setting auth_type="azure-cli" on a GCP host was silently ignored. Now DefaultCredentials owns the cloud filtering: a cloudRequirements map in credentialsChain associates each cloud-specific strategy with its required cloud. In auto-detect mode, mismatched strategies are skipped with a debug log. When auth_type is explicitly set, the map is not consulted and the named strategy is always attempted regardless of the detected host cloud. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Signed-off-by: Hector Castejon Diaz <[email protected]>
tanmay-db
approved these changes
Mar 3, 2026
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
This was referenced Mar 3, 2026
hectorcast-db
added a commit
to databricks/databricks-sdk-java
that referenced
this pull request
Mar 5, 2026
Azure strategies (azure-cli, azure-client-secret, github-oidc-azure) are now skipped on GCP/AWS hosts in auto-detect mode. GCP strategies (google-credentials, google-id) are skipped on Azure/AWS hosts. When authType is explicitly set, cloud filtering is bypassed so the named strategy is always attempted regardless of host cloud. Individual credential providers no longer perform their own isAzure()/isGcp() checks — that responsibility now lives centrally in DefaultCredentialsProvider via a CLOUD_REQUIREMENTS map, mirroring the approach taken in databricks/databricks-sdk-go#1505. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
4 tasks
hectorcast-db
added a commit
that referenced
this pull request
Mar 5, 2026
…CloudRequirements PR #1505 changed NewCredentialsChain to return *credentialsChain (unexported) to enable WithCloudRequirements chaining. This broke the public API. Restore the return type to CredentialsStrategy and introduce NewCredentialsChainWithCloudRequirements for callers that need cloud-based filtering. DefaultCredentials now uses the new constructor directly. The WithCloudRequirements method is removed as it is no longer needed. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Signed-off-by: Hector Castejon Diaz <[email protected]>
hectorcast-db
added a commit
that referenced
this pull request
Mar 5, 2026
…CloudRequirements PR #1505 changed NewCredentialsChain to return *credentialsChain (unexported) to enable WithCloudRequirements chaining. This broke the public API. Restore the return type to CredentialsStrategy and introduce NewCredentialsChainWithCloudRequirements for callers that need cloud-based filtering. DefaultCredentials now uses the new constructor directly. The WithCloudRequirements method is removed as it is no longer needed. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Signed-off-by: Hector Castejon Diaz <[email protected]>
hectorcast-db
added a commit
that referenced
this pull request
Mar 5, 2026
…CloudRequirements PR #1505 changed NewCredentialsChain to return *credentialsChain (unexported) to enable WithCloudRequirements chaining. This broke the public API. Restore the return type to CredentialsStrategy and introduce NewCredentialsChainWithCloudRequirements for callers that need cloud-based filtering. DefaultCredentials now uses the new constructor directly. The WithCloudRequirements method is removed as it is no longer needed. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Signed-off-by: Hector Castejon Diaz <[email protected]>
hectorcast-db
added a commit
that referenced
this pull request
Mar 5, 2026
…CloudRequirements PR #1505 changed NewCredentialsChain to return *credentialsChain (unexported) to enable WithCloudRequirements chaining. This broke the public API. Restore the return type to CredentialsStrategy and introduce NewCredentialsChainWithCloudRequirements for callers that need cloud-based filtering. DefaultCredentials now uses the new constructor directly. The WithCloudRequirements method is removed as it is no longer needed. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Signed-off-by: Hector Castejon Diaz <[email protected]>
hectorcast-db
added a commit
that referenced
this pull request
Mar 6, 2026
…#1505) ## Changes Move Cloud filtering from each Credentials Strategy to the DefaultCredentialStrategy. **Problem:** Each Azure/GCP strategy previously contained its own host-cloud guard (e.g. `AzureCliCredentials` returned `nil, nil` on a non-Azure host). This meant that explicitly setting `auth_type="azure-cli"` on a GCP host was silently ignored — the strategy would just return nil. **Solution:** Cloud filtering moves into the `DefaultCredentials` orchestrator via a `cloudRequirements` map on `credentialsChain`: - In **auto-detect mode** (`auth_type` not set): Azure strategies are skipped on GCP/AWS hosts and GCP strategies are skipped on Azure/AWS hosts. Each skip is logged at debug level: `Skipping "azure-cli": not configured for Azure`. - When **`auth_type` is explicitly set**: the `cloudRequirements` map is not consulted and the named strategy is always attempted, regardless of detected host cloud. This enables e.g. `auth_type="azure-cli"` to work on a host whose cloud is unknown. Individual strategies no longer contain `cfg.IsAzure()` / `cfg.IsGcp()` guards — that responsibility belongs entirely to the orchestrator. **Files changed:** - `config/auth_default.go` — `credentialsChain` gains `cloudRequirements map[string]environment.Cloud` and a `WithCloudRequirements` builder; `DefaultCredentials.Configure` wires it up via `NewCredentialsChain(...).WithCloudRequirements(...)` - `config/auth_azure_cli.go`, `auth_azure_msi.go`, `auth_azure_client_secret.go`, `auth_azure_github_oidc.go` — removed `cfg.IsAzure()` guards - `config/auth_gcp_google_credentials.go`, `auth_gcp_google_id.go` — removed `cfg.IsGcp()` guards ## Tests - `TestCredentialsChain_CloudFiltering_SkipsOnCloudMismatch` — chain skips an Azure strategy on a GCP host in auto-detect mode - `TestCredentialsChain_CloudFiltering_BypassesOnExplicitAuthType` — chain attempts the Azure strategy on a GCP host when `auth_type` is explicitly set 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Hector Castejon Diaz <[email protected]> Co-authored-by: Claude Sonnet 4.6 <[email protected]>
github-merge-queue bot
pushed a commit
that referenced
this pull request
Mar 11, 2026
## Summary - Reverts PR #1505 which moved cloud filtering logic from individual credential strategies to `DefaultCredentials` - Restores the original behavior where each Azure/GCP strategy contains its own `IsAzure()` / `IsGcp()` guard ## Changes Reverts the following changes from #1505: - Removes `cloudRequirements` map and `WithCloudRequirements` builder from `credentialsChain` in `config/auth_default.go` - Restores `IsAzure()` / `IsGcp()` guards in individual Azure and GCP credential strategies - Removes cloud filtering tests from `config/auth_default_test.go` - Removes test for Azure CLI credentials skipping on AWS hosts from `config/auth_azure_cli_test.go` - Removes changelog entry for the reverted feature ## Tests Existing unit tests cover the restored behavior. NO_CHANGELOG=true
3 tasks
github-merge-queue bot
pushed a commit
to databricks/cli
that referenced
this pull request
Mar 12, 2026
## Summary - Clear `PATH` in `cmd/root` auth tests to prevent the Go SDK (v0.117.0+) from shelling out to `az account show` during credential resolution - For `TestBundleConfigureDefault`, restrict `PATH` to system directories instead of clearing it fully — the bundle loader's script hook mutator currently requires a shell to be present even when no scripts are configured (fixing that separately) - Normalize existing `PATH="/nothing"` in prompt tests to `PATH=""` The SDK upgrade to v0.117.0 (databricks/databricks-sdk-go#1505, bumped in #4631) removed per-strategy cloud guards from Azure CLI credentials, causing `az` to be probed on all platforms regardless of the configured host. This added ~0.5–2.5s per affected test and wrote `.azure/` cache files into the source tree. Verified on macOS and Windows. ## Test plan - [x] `go test -count=1 ./cmd/root` passes on macOS (1.2s, down from 5.2s) - [x] `go test -count=1 ./cmd/root` passes on Windows (0.19s) - [x] No `.azure/` or `Library/` directories created in `cmd/root/` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
rauchy
pushed a commit
to databricks/cli
that referenced
this pull request
Mar 17, 2026
## Summary - Clear `PATH` in `cmd/root` auth tests to prevent the Go SDK (v0.117.0+) from shelling out to `az account show` during credential resolution - For `TestBundleConfigureDefault`, restrict `PATH` to system directories instead of clearing it fully — the bundle loader's script hook mutator currently requires a shell to be present even when no scripts are configured (fixing that separately) - Normalize existing `PATH="/nothing"` in prompt tests to `PATH=""` The SDK upgrade to v0.117.0 (databricks/databricks-sdk-go#1505, bumped in #4631) removed per-strategy cloud guards from Azure CLI credentials, causing `az` to be probed on all platforms regardless of the configured host. This added ~0.5–2.5s per affected test and wrote `.azure/` cache files into the source tree. Verified on macOS and Windows. ## Test plan - [x] `go test -count=1 ./cmd/root` passes on macOS (1.2s, down from 5.2s) - [x] `go test -count=1 ./cmd/root` passes on Windows (0.19s) - [x] No `.azure/` or `Library/` directories created in `cmd/root/` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
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.
Changes
Move Cloud filtering from each Credentials Strategy to the DefaultCredentialStrategy.
Problem: Each Azure/GCP strategy previously contained its own host-cloud guard (e.g.
AzureCliCredentialsreturnednil, nilon a non-Azure host). This meant that explicitly settingauth_type="azure-cli"on a GCP host was silently ignored — the strategy would just return nil.Solution: Cloud filtering moves into the
DefaultCredentialsorchestrator via acloudRequirementsmap oncredentialsChain:auth_typenot set): Azure strategies are skipped on GCP/AWS hosts and GCP strategies are skipped on Azure/AWS hosts. Each skip is logged at debug level:Skipping "azure-cli": not configured for Azure.auth_typeis explicitly set: thecloudRequirementsmap is not consulted and the named strategy is always attempted, regardless of detected host cloud. This enables e.g.auth_type="azure-cli"to work on a host whose cloud is unknown.Individual strategies no longer contain
cfg.IsAzure()/cfg.IsGcp()guards — that responsibility belongs entirely to the orchestrator.Files changed:
config/auth_default.go—credentialsChaingainscloudRequirements map[string]environment.Cloudand aWithCloudRequirementsbuilder;DefaultCredentials.Configurewires it up viaNewCredentialsChain(...).WithCloudRequirements(...)config/auth_azure_cli.go,auth_azure_msi.go,auth_azure_client_secret.go,auth_azure_github_oidc.go— removedcfg.IsAzure()guardsconfig/auth_gcp_google_credentials.go,auth_gcp_google_id.go— removedcfg.IsGcp()guardsTests
TestCredentialsChain_CloudFiltering_SkipsOnCloudMismatch— chain skips an Azure strategy on a GCP host in auto-detect modeTestCredentialsChain_CloudFiltering_BypassesOnExplicitAuthType— chain attempts the Azure strategy on a GCP host whenauth_typeis explicitly set🤖 Generated with Claude Code