Skip to content

Commit 3af6cbb

Browse files
committed
Remove unified flag usage, rely on host metadata
Port of Python SDK PR #1331. HostType() no longer returns UnifiedHost; host type is determined solely by URL pattern. EnsureResolved() now always resolves host metadata when a host is configured (not gated behind Experimental_IsUnifiedHost). IsAccountClient() no longer panics on unified hosts. ConfigType() returns WorkspaceConfig for account hosts with WorkspaceID. buildHostCommand() no longer has a UnifiedHost case. getOidcEndpoints() and getOAuthArgument() remove UnifiedHost cases, relying on DiscoveryURL from metadata. The Experimental_IsUnifiedHost field and UnifiedHost const remain in the codebase for backward compatibility but are no longer checked. Note: codegen templates in service/ files still check for UnifiedHost and need to be updated in the codegen repo to use cfg.WorkspaceID directly. Co-authored-by: Isaac
1 parent 35c18cb commit 3af6cbb

8 files changed

Lines changed: 185 additions & 282 deletions

File tree

account_functions.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ func (c *AccountClient) GetWorkspaceClient(ws provisioning.Workspace) (*Workspac
6363
}
6464
cfg.AzureResourceID = ws.AzureResourceId()
6565
cfg.WorkspaceID = fmt.Sprintf("%d", ws.WorkspaceId)
66-
if c.Config.Experimental_IsUnifiedHost {
67-
cfg.AccountID = c.Config.AccountID
68-
cfg.Experimental_IsUnifiedHost = true
69-
}
7066
w, err := NewWorkspaceClient((*Config)(cfg))
7167
if err != nil {
7268
return nil, err

config/auth_oidc_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ func TestGithubOIDC_Scopes(t *testing.T) {
7474
"expires_in": 3600,
7575
})
7676

77+
case "/.well-known/databricks-config":
78+
http.Error(w, "Not found", http.StatusNotFound)
79+
7780
default:
7881
t.Errorf("Unexpected request: %s %s", r.Method, r.URL.Path)
7982
http.Error(w, "Not found", http.StatusNotFound)

config/cli_token_source.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ func buildCliCommands(cliPath string, cfg *Config) (primaryCmd []string, hostCmd
7070
func buildHostCommand(cliPath string, cfg *Config) []string {
7171
cmd := []string{cliPath, "auth", "token", "--host", cfg.Host}
7272
switch cfg.HostType() {
73-
case UnifiedHost:
74-
cmd = append(cmd, "--experimental-is-unified-host")
75-
if cfg.AccountID != "" {
76-
cmd = append(cmd, "--account-id", cfg.AccountID)
77-
}
78-
if cfg.WorkspaceID != "" {
79-
cmd = append(cmd, "--workspace-id", cfg.WorkspaceID)
80-
}
8173
case AccountHost:
8274
cmd = append(cmd, "--account-id", cfg.AccountID)
8375
}

config/cli_token_source_test.go

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -152,50 +152,14 @@ func TestBuildCliCommands(t *testing.T) {
152152
wantCmd: []string{cliPath, "auth", "token", "--host", accountHost, "--account-id", accountID},
153153
},
154154
{
155-
name: "unified host with account ID and workspace ID",
155+
name: "former unified host treated as workspace",
156156
cfg: &Config{
157157
Host: unifiedHost,
158158
Experimental_IsUnifiedHost: true,
159159
AccountID: accountID,
160160
WorkspaceID: workspaceID,
161161
},
162-
wantCmd: []string{cliPath, "auth", "token", "--host", unifiedHost, "--experimental-is-unified-host", "--account-id", accountID, "--workspace-id", workspaceID},
163-
},
164-
{
165-
name: "unified host with account ID only",
166-
cfg: &Config{
167-
Host: unifiedHost,
168-
Experimental_IsUnifiedHost: true,
169-
AccountID: accountID,
170-
},
171-
wantCmd: []string{cliPath, "auth", "token", "--host", unifiedHost, "--experimental-is-unified-host", "--account-id", accountID},
172-
},
173-
{
174-
name: "unified host with workspace ID only",
175-
cfg: &Config{
176-
Host: unifiedHost,
177-
Experimental_IsUnifiedHost: true,
178-
WorkspaceID: workspaceID,
179-
},
180-
wantCmd: []string{cliPath, "auth", "token", "--host", unifiedHost, "--experimental-is-unified-host", "--workspace-id", workspaceID},
181-
},
182-
{
183-
name: "unified host with no account ID or workspace ID",
184-
cfg: &Config{
185-
Host: unifiedHost,
186-
Experimental_IsUnifiedHost: true,
187-
},
188-
wantCmd: []string{cliPath, "auth", "token", "--host", unifiedHost, "--experimental-is-unified-host"},
189-
},
190-
{
191-
// Explicit false should fall back to the standard host type detection
192-
name: "unified host false with account host",
193-
cfg: &Config{
194-
Host: accountHost,
195-
Experimental_IsUnifiedHost: false,
196-
AccountID: accountID,
197-
},
198-
wantCmd: []string{cliPath, "auth", "token", "--host", accountHost, "--account-id", accountID},
162+
wantCmd: []string{cliPath, "auth", "token", "--host", unifiedHost},
199163
},
200164
{
201165
name: "profile uses --profile with --host fallback",

config/config.go

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,9 @@ func (c *Config) IsAws() bool {
379379
}
380380

381381
// IsAccountClient returns true if client is configured for Accounts API.
382-
// Panics if the config has the unified host flag set.
383382
//
384383
// Deprecated: Use HostType() if possible, or ConfigType() if necessary.
385384
func (c *Config) IsAccountClient() bool {
386-
if c.Experimental_IsUnifiedHost {
387-
panic("IsAccountClient cannot be used with unified hosts; use HostType() instead")
388-
}
389-
390385
if c.AccountID != "" && c.isTesting {
391386
return true
392387
}
@@ -413,11 +408,9 @@ func normalizedHost(host string) string {
413408
}
414409

415410
// HostType returns the type of host that the client is configured for.
411+
// HostType now only returns WorkspaceHost or AccountHost. UnifiedHost is
412+
// deprecated; host metadata resolution handles unified host behavior.
416413
func (c *Config) HostType() HostType {
417-
if c.Experimental_IsUnifiedHost {
418-
return UnifiedHost
419-
}
420-
421414
// TODO: Refactor tests so that this is not needed.
422415
if c.AccountID != "" && c.isTesting {
423416
return AccountHost
@@ -449,18 +442,12 @@ func (c *Config) HostType() HostType {
449442
func (c *Config) ConfigType() ConfigType {
450443
switch c.HostType() {
451444
case AccountHost:
452-
return AccountConfig
453-
case WorkspaceHost:
454-
return WorkspaceConfig
455-
case UnifiedHost:
456-
if c.AccountID == "" {
457-
// All unified host configs must have an account ID
458-
return InvalidConfig
459-
}
460445
if c.WorkspaceID != "" {
461446
return WorkspaceConfig
462447
}
463448
return AccountConfig
449+
case WorkspaceHost:
450+
return WorkspaceConfig
464451
default:
465452
return InvalidConfig
466453
}
@@ -520,13 +507,14 @@ func (c *Config) EnsureResolved() error {
520507
}
521508
slices.Sort(c.Scopes)
522509
c.Scopes = slices.Compact(c.Scopes)
523-
if c.Experimental_IsUnifiedHost && c.Host != "" {
524-
_ = c.fixHostIfNeeded()
525-
meta, err := getHostMetadata(ctx, c.CanonicalHostName(), c.refreshClient)
526-
if err != nil {
527-
logger.Warnf(ctx, "Failed to resolve host metadata: %v. Falling back to user config.", err)
528-
} else {
529-
c.applyHostMetadata(ctx, meta)
510+
if c.Host != "" {
511+
if err := c.fixHostIfNeeded(); err == nil {
512+
meta, err := getHostMetadata(ctx, c.CanonicalHostName(), c.refreshClient)
513+
if err != nil {
514+
logger.Warnf(ctx, "Failed to resolve host metadata: %v. Falling back to user config.", err)
515+
} else {
516+
c.applyHostMetadata(ctx, meta)
517+
}
530518
}
531519
}
532520
c.resolved = true
@@ -659,8 +647,6 @@ func (c *Config) getOidcEndpoints(ctx context.Context) (*u2m.OAuthAuthorizationS
659647
switch c.HostType() {
660648
case AccountHost:
661649
return oauthClient.GetAccountOAuthEndpoints(ctx, host, c.AccountID)
662-
case UnifiedHost:
663-
return oauthClient.GetUnifiedOAuthEndpoints(ctx, host, c.AccountID)
664650
case WorkspaceHost:
665651
return oauthClient.GetWorkspaceOAuthEndpoints(ctx, host)
666652
default:
@@ -752,8 +738,6 @@ func (c *Config) getOAuthArgument() (u2m.OAuthArgument, error) {
752738
switch c.HostType() {
753739
case AccountHost:
754740
return u2m.NewProfileAccountOAuthArgument(host, c.AccountID, profile)
755-
case UnifiedHost:
756-
return u2m.NewProfileUnifiedOAuthArgument(host, c.AccountID, profile)
757741
case WorkspaceHost:
758742
return u2m.NewProfileWorkspaceOAuthArgument(host, profile)
759743
default:

0 commit comments

Comments
 (0)