diff --git a/cmd/baton-databricks/main.go b/cmd/baton-databricks/main.go index 6a738967..a1b272c3 100644 --- a/cmd/baton-databricks/main.go +++ b/cmd/baton-databricks/main.go @@ -20,6 +20,7 @@ import ( var ( connectorName = "baton-databricks" version = "dev" + defaultHost = "cloud.databricks.com" ) func main() { @@ -58,7 +59,7 @@ func prepareClientAuth(ctx context.Context, cfg *viper.Viper) databricks.Auth { password := cfg.GetString(config.PasswordField.FieldName) workspaces := cfg.GetStringSlice(config.WorkspacesField.FieldName) tokens := cfg.GetStringSlice(config.TokensField.FieldName) - accountHostname := databricks.GetAccountHostname(databricks.GetHostname(cfg)) + accountHostname := databricks.GetAccountHostname(getHostname(cfg)) switch { case username != "" && password != "": @@ -108,8 +109,8 @@ func getConnector(ctx context.Context, cfg *viper.Viper) (types.ConnectorServer, return nil, err } - hostname := databricks.GetHostname(cfg) - accountHostname := databricks.GetAccountHostname(databricks.GetHostname(cfg)) + hostname := getHostname(cfg) + accountHostname := databricks.GetAccountHostname(getHostname(cfg)) auth := prepareClientAuth(ctx, cfg) cb, err := connector.New( ctx, @@ -132,3 +133,10 @@ func getConnector(ctx context.Context, cfg *viper.Viper) (types.ConnectorServer, return c, nil } + +func getHostname(cfg *viper.Viper) string { + if cfg.GetString(config.HostnameField.FieldName) == "" { + return defaultHost + } + return cfg.GetString(config.HostnameField.FieldName) +} diff --git a/pkg/databricks/client.go b/pkg/databricks/client.go index 4b6bc51b..905369b7 100644 --- a/pkg/databricks/client.go +++ b/pkg/databricks/client.go @@ -7,16 +7,13 @@ import ( "net/url" "strings" - "github.com/conductorone/baton-databricks/cmd/baton-databricks/config" v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2" "github.com/conductorone/baton-sdk/pkg/uhttp" - "github.com/spf13/viper" ) const ( - defaultHost = "cloud.databricks.com" - azureHost = "azuredatabricks.net" - gcpHost = "gcp.databricks.net" + azureHost = "azuredatabricks.net" + gcpHost = "gcp.databricks.net" // Some of these are case sensitive. usersEndpoint = "/api/2.0/preview/scim/v2/Users" @@ -47,13 +44,6 @@ type Client struct { isWSAPIAvailable bool } -func GetHostname(cfg *viper.Viper) string { - if cfg.GetString(config.HostnameField.FieldName) == "" { - return defaultHost - } - return cfg.GetString(config.HostnameField.FieldName) -} - func GetAccountHostname(hostname string) string { if strings.HasSuffix(hostname, azureHost) { return "accounts." + azureHost