Skip to content

Commit e215490

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 fc86ca0 commit e215490

File tree

8 files changed

+158
-262
lines changed

8 files changed

+158
-262
lines changed

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: 5 additions & 24 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,9 +507,7 @@ func (c *Config) EnsureResolved() error {
520507
}
521508
slices.Sort(c.Scopes)
522509
c.Scopes = slices.Compact(c.Scopes)
523-
if c.Experimental_IsUnifiedHost {
524-
c.resolveHostMetadata(ctx)
525-
}
510+
c.resolveHostMetadata(ctx)
526511
c.resolved = true
527512
return nil
528513
}
@@ -653,8 +638,6 @@ func (c *Config) getOidcEndpoints(ctx context.Context) (*u2m.OAuthAuthorizationS
653638
switch c.HostType() {
654639
case AccountHost:
655640
return oauthClient.GetAccountOAuthEndpoints(ctx, host, c.AccountID)
656-
case UnifiedHost:
657-
return oauthClient.GetUnifiedOAuthEndpoints(ctx, host, c.AccountID)
658641
case WorkspaceHost:
659642
return oauthClient.GetWorkspaceOAuthEndpoints(ctx, host)
660643
default:
@@ -733,8 +716,6 @@ func (c *Config) getOAuthArgument() (u2m.OAuthArgument, error) {
733716
switch c.HostType() {
734717
case AccountHost:
735718
return u2m.NewProfileAccountOAuthArgument(host, c.AccountID, profile)
736-
case UnifiedHost:
737-
return u2m.NewProfileUnifiedOAuthArgument(host, c.AccountID, profile)
738719
case WorkspaceHost:
739720
return u2m.NewProfileWorkspaceOAuthArgument(host, profile)
740721
default:

0 commit comments

Comments
 (0)