Skip to content

Commit 8d0c6e0

Browse files
authored
[Internal] Remove resolved host metadata from HostType() method (#1630)
## Changes Removing this to unblock the Terraform provider release followed by the Go SDK bump. Partially reverts #1606 — removes the `resolvedHostType` early-return in `HostType()` and the associated tests. Specifically: - Removes the `if c.resolvedHostType != HostTypeUnknown { return c.resolvedHostType }` block from `HostType()` - Removes the `// When host metadata has been resolved...` comment that described the reverted behavior - Keeps the `// Deprecated:` comment on `HostType()` - Removes 7 test cases that validated the metadata-first behavior (`TestHostType_UsesMetadataFirst_*`, `TestHostType_FallsBackToURLWhenMetadataUnknown*`, `TestHostType_MetadataOverridesExperimentalFlag`, `TestHostType_EndToEnd_MetadataResolvesHostType`) - Removes the changelog entry for this change `HostType()` now returns to its pre-#1606 behavior: URL-pattern-only detection, which is what downstream consumers (TF provider) still rely on. NO_CHANGELOG=true ## Tests Existing `config` package tests pass (`go test ./config/...`). The removed tests were specific to the reverted behavior. Signed-off-by: Tanmay Rustagi <tanmay.rustagi@databricks.com>
1 parent 44ebcb4 commit 8d0c6e0

3 files changed

Lines changed: 0 additions & 78 deletions

File tree

NEXT_CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
### Internal Changes
2727

28-
* Use resolved host type from host metadata in `HostType()` method, falling back to URL pattern matching when metadata is unavailable.
2928
* Normalize internal token sources on `auth.TokenSource` for proper context propagation ([#1577](https://github.com/databricks/databricks-sdk-go/pull/1577)).
3029
* 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)).
3130
* Bump golang.org/x/crypto from 0.21.0 to 0.45.0 in /examples/slog ([#1566](https://github.com/databricks/databricks-sdk-go/pull/1566)).

config/config.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -447,19 +447,11 @@ func normalizedHost(host string) string {
447447
}
448448

449449
// HostType returns the type of host that the client is configured for.
450-
// When host metadata has been resolved (via /.well-known/databricks-config),
451-
// the resolved host type is returned directly. Otherwise, the host type is
452-
// inferred from URL patterns as a fallback.
453450
//
454451
// Deprecated: The SDK is moving towards host-agnostic behavior where host URL
455452
// patterns are no longer used to determine client capabilities. This method is
456453
// retained for backwards compatibility but should not be used in new code.
457454
func (c *Config) HostType() HostType {
458-
// If host metadata resolved a known host type, use it.
459-
if c.resolvedHostType != HostTypeUnknown {
460-
return c.resolvedHostType
461-
}
462-
463455
// TODO: Remove this after TF updates its code.
464456
if c.Experimental_IsUnifiedHost {
465457
return UnifiedHost

config/config_test.go

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -86,75 +86,6 @@ func TestHostType_UnifiedFlagNoLongerReturnsUnified(t *testing.T) {
8686
assert.Equal(t, WorkspaceHost, c.HostType())
8787
}
8888

89-
func TestHostType_UsesMetadataFirst_Workspace(t *testing.T) {
90-
c := &Config{
91-
Host: "https://accounts.cloud.databricks.com",
92-
resolvedHostType: WorkspaceHost,
93-
}
94-
assert.Equal(t, WorkspaceHost, c.HostType())
95-
}
96-
97-
func TestHostType_UsesMetadataFirst_Account(t *testing.T) {
98-
c := &Config{
99-
Host: "https://my-workspace.cloud.databricks.com",
100-
resolvedHostType: AccountHost,
101-
}
102-
assert.Equal(t, AccountHost, c.HostType())
103-
}
104-
105-
func TestHostType_UsesMetadataFirst_Unified(t *testing.T) {
106-
c := &Config{
107-
Host: "https://my-workspace.cloud.databricks.com",
108-
resolvedHostType: UnifiedHost,
109-
}
110-
assert.Equal(t, UnifiedHost, c.HostType())
111-
}
112-
113-
func TestHostType_FallsBackToURLWhenMetadataUnknown(t *testing.T) {
114-
c := &Config{
115-
Host: "https://accounts.cloud.databricks.com",
116-
resolvedHostType: HostTypeUnknown,
117-
}
118-
assert.Equal(t, AccountHost, c.HostType())
119-
}
120-
121-
func TestHostType_FallsBackToURLWhenMetadataUnknown_Workspace(t *testing.T) {
122-
c := &Config{
123-
Host: "https://my-workspace.cloud.databricks.com",
124-
resolvedHostType: HostTypeUnknown,
125-
}
126-
assert.Equal(t, WorkspaceHost, c.HostType())
127-
}
128-
129-
func TestHostType_MetadataOverridesExperimentalFlag(t *testing.T) {
130-
c := &Config{
131-
Host: "https://my-workspace.cloud.databricks.com",
132-
Experimental_IsUnifiedHost: true,
133-
resolvedHostType: AccountHost,
134-
}
135-
assert.Equal(t, AccountHost, c.HostType())
136-
}
137-
138-
func TestHostType_EndToEnd_MetadataResolvesHostType(t *testing.T) {
139-
noopLoader := mockLoader(func(cfg *Config) error { return nil })
140-
cfg := &Config{
141-
Host: "https://my-workspace.cloud.databricks.com",
142-
Loaders: []Loader{noopLoader},
143-
HTTPTransport: fixtures.SliceTransport{
144-
{
145-
Method: "GET",
146-
Resource: "/.well-known/databricks-config",
147-
ReuseRequest: true,
148-
Status: 200,
149-
Response: `{"oidc_endpoint": "https://my-workspace.cloud.databricks.com/oidc", "account_id": "` + testHMAccountID + `", "host_type": "account"}`,
150-
},
151-
},
152-
}
153-
err := cfg.EnsureResolved()
154-
require.NoError(t, err)
155-
assert.Equal(t, AccountHost, cfg.HostType())
156-
}
157-
15889
func TestIsAccountClient_NoLongerPanicsOnUnifiedHost(t *testing.T) {
15990
c := &Config{
16091
Host: "https://unified.cloud.databricks.com",

0 commit comments

Comments
 (0)