Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use viper so we can reuse this logic in c1 #17

Merged
merged 1 commit into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/baton-databricks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,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(cfg)
accountHostname := databricks.GetAccountHostname(databricks.GetHostname(cfg))

switch {
case username != "" && password != "":
Expand Down Expand Up @@ -109,7 +109,7 @@ func getConnector(ctx context.Context, cfg *viper.Viper) (types.ConnectorServer,
}

hostname := databricks.GetHostname(cfg)
accountHostname := databricks.GetAccountHostname(cfg)
accountHostname := databricks.GetAccountHostname(databricks.GetHostname(cfg))
auth := prepareClientAuth(ctx, cfg)
cb, err := connector.New(
ctx,
Expand Down
8 changes: 4 additions & 4 deletions pkg/databricks/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ func GetHostname(cfg *viper.Viper) string {
return cfg.GetString(config.HostnameField.FieldName)
}

func GetAccountHostname(cfg *viper.Viper) string {
if strings.HasSuffix(GetHostname(cfg), azureHost) {
func GetAccountHostname(hostname string) string {
if strings.HasSuffix(hostname, azureHost) {
return "accounts." + azureHost
} else if strings.HasSuffix(GetHostname(cfg), gcpHost) {
} else if strings.HasSuffix(hostname, gcpHost) {
return "accounts." + gcpHost
}
return "accounts." + GetHostname(cfg)
return "accounts." + hostname
}

func NewClient(ctx context.Context, httpClient *http.Client, hostname, accountHostname, accountID string, auth Auth) (*Client, error) {
Expand Down
Loading