Skip to content

Commit b168ea9

Browse files
committed
update
1 parent 426de31 commit b168ea9

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

compute/v2/ext_utilities.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ func (a *ClustersClient) EnsureClusterIsRunning(ctx context.Context, clusterId s
141141
})
142142
}
143143

144+
// TODO: This method currently contains cloud-specific logic (AWS vs others) that requires
145+
// the client to be aware of the cloud provider. However, we don't want client to contain
146+
// information about the cloud. We're temporarily including this method, but need to
147+
// decide on a better approach for handling these mixins before the SDK-Mod release.
148+
//
144149
// GetOrCreateRunningCluster creates an autoterminating cluster if it doesn't exist
145150
func (a *ClustersClient) GetOrCreateRunningCluster(ctx context.Context, name string, custom ...CreateCluster) (c *ClusterDetails, err error) {
146151
getOrCreateClusterMutex.Lock()

databricks/config/api_client.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"time"
1010

1111
"github.com/databricks/databricks-sdk-go/databricks/apierr"
12+
"github.com/databricks/databricks-sdk-go/databricks/common/environment"
1213
"github.com/databricks/databricks-sdk-go/databricks/config/credentials"
1314
"github.com/databricks/databricks-sdk-go/databricks/httpclient"
1415
"github.com/databricks/databricks-sdk-go/databricks/useragent"
@@ -26,12 +27,21 @@ func HTTPClientConfigFromConfig(cfg *Config) (httpclient.ClientConfig, error) {
2627
if err != nil {
2728
return httpclient.ClientConfig{}, err
2829
}
29-
30+
var cloud environment.Cloud
31+
switch {
32+
case cfg.IsAzure():
33+
cloud = environment.CloudAzure
34+
case cfg.IsAws():
35+
cloud = environment.CloudAWS
36+
case cfg.IsGcp():
37+
cloud = environment.CloudGCP
38+
default:
39+
return httpclient.ClientConfig{}, fmt.Errorf("unable to determine cloud from config")
40+
}
3041
return httpclient.ClientConfig{
3142
AccountID: cfg.AccountID,
3243
Host: cfg.Host,
33-
AzureResourceID: cfg.AzureResourceID,
34-
Cloud: cfg.Environment().Cloud,
44+
Cloud: cloud,
3545
RetryTimeout: time.Duration(cfg.RetryTimeoutSeconds) * time.Second,
3646
HTTPTimeout: time.Duration(cfg.HTTPTimeoutSeconds) * time.Second,
3747
RateLimitPerSecond: cfg.RateLimitPerSecond,

databricks/httpclient/api_client.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ type ClientConfig struct {
2626
AuthVisitor RequestVisitor
2727
Visitors []RequestVisitor
2828

29-
AccountID string
30-
Host string
31-
Cloud environment.Cloud
32-
AzureResourceID string
29+
AccountID string
30+
Host string
31+
// TODO: Ideally we should not have knowledge of the cloud in the client config.
32+
// But `getOrCreateRunningCluster` in `compute/v2/ext_utilities.go` uses this to determine the cloud.
33+
// So, we are keeping it for now. But we should reconsider this approach before finalizing the SDK-Mod release.
34+
Cloud environment.Cloud
3335

3436
RetryTimeout time.Duration
3537
HTTPTimeout time.Duration
@@ -81,9 +83,6 @@ func (apic *ApiClient) AccountID() string {
8183

8284
// IsAzure returns if the client is configured for Azure Databricks.
8385
func (apic *ApiClient) IsAzure() bool {
84-
if apic.config.AzureResourceID != "" {
85-
return true
86-
}
8786
return apic.config.Cloud == environment.CloudAzure
8887
}
8988

@@ -94,7 +93,7 @@ func (apic *ApiClient) IsGcp() bool {
9493

9594
// IsAws returns if the client is configured for Databricks on AWS.
9695
func (apic *ApiClient) IsAws() bool {
97-
return apic.config.Host != "" && !apic.IsAzure() && !apic.IsGcp()
96+
return apic.config.Cloud == environment.CloudAWS
9897
}
9998

10099
const (

0 commit comments

Comments
 (0)