Skip to content

Commit 21f56ce

Browse files
committed
Bring back removed functions and errors
1 parent 2e61308 commit 21f56ce

4 files changed

Lines changed: 34 additions & 7 deletions

File tree

account_client.go

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/config.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,29 @@ func (c *Config) IsAws() bool {
303303
return c.Host != "" && !c.IsAzure() && !c.IsGcp()
304304
}
305305

306+
// IsAccountClient returns true if client is configured for Accounts API.
307+
// Panics if the config has the unified host flag set.
308+
func (c *Config) IsAccountClient() bool {
309+
if c.Experimental_IsUnifiedHost {
310+
panic("IsAccountClient cannot be used with unified hosts; use GetHostType() instead")
311+
}
312+
313+
if c.AccountID != "" && c.isTesting {
314+
return true
315+
}
316+
317+
accountsPrefixes := []string{
318+
"https://accounts.",
319+
"https://accounts-dod.",
320+
}
321+
for _, prefix := range accountsPrefixes {
322+
if strings.HasPrefix(c.Host, prefix) {
323+
return true
324+
}
325+
}
326+
return false
327+
}
328+
306329
// GetHostType returns one of WORKSPACE_HOST, ACCOUNT_HOST, or UNIFIED HOST
307330
func (c *Config) GetHostType() HostTypeEnum {
308331
if c.Experimental_IsUnifiedHost {

internal/acceptance_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func TestAccErrNotAccountClient(t *testing.T) {
137137
// Confirm that we get an error when trying to create an account client
138138
// if the configuration indicates a workspace.
139139
_, err := databricks.NewAccountClient()
140-
assert.ErrorIs(t, err, databricks.ErrInvalidAccountConfig)
140+
assert.ErrorIs(t, err, databricks.ErrNotAccountClient)
141141
}
142142

143143
func TestAccErrNotWorkspaceClient(t *testing.T) {

workspace_client.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)