Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ to work with only specified workspaces and their respective tokens. You can
provide multiple tokens by separating them with a comma. This method requires
admin access to each workspace you want to sync.

# Using Azure Databricks

To work with Azure Databricks, you need to provide the hostname flag.

```bash
baton-databricks --hostname "azuredatabricks.net"
```

# Getting Started

## brew
Expand Down Expand Up @@ -120,6 +128,7 @@ Flags:
--databricks-client-secret string The Databricks service principal's client secret used to connect to the Databricks Account and Workspace API ($BATON_DATABRICKS_CLIENT_SECRET)
-f, --file string The path to the c1z file to sync with ($BATON_FILE) (default "sync.c1z")
-h, --help help for baton-databricks
--hostname The Databricks hostname used to connect to the Databricks API ($BATON_HOSTNAME) (default "cloud.databricks.com")
--log-format string The output format for logs: json, console ($BATON_LOG_FORMAT) (default "json")
--log-level string The log level: debug, info, warn, error ($BATON_LOG_LEVEL) (default "info")
--password string The Databricks password used to connect to the Databricks API ($BATON_PASSWORD)
Expand Down
2 changes: 2 additions & 0 deletions cmd/baton-databricks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +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)
hostname := cfg.GetString(config.HostnameField.FieldName)

switch {
case username != "" && password != "":
Expand All @@ -81,6 +82,7 @@ func prepareClientAuth(ctx context.Context, cfg *viper.Viper) databricks.Auth {
accountID,
databricksClientId,
databricksClientSecret,
hostname,
)
return cAuth
case AreTokensSet(workspaces, tokens):
Expand Down
1 change: 0 additions & 1 deletion pkg/config/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ var (
AccountHostnameField = field.StringField(
"account-hostname",
field.WithDescription("The hostname used to connect to the Databricks account API"),
field.WithDefaultValue("accounts.cloud.databricks.com"),
)
AccountIdField = field.StringField(
"account-id",
Expand Down
4 changes: 2 additions & 2 deletions pkg/databricks/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ type OAuth2 struct {
cfg *clientcredentials.Config
}

func NewOAuth2(accId, clientId, clientSecret string) *OAuth2 {
func NewOAuth2(accId, clientId, clientSecret, hostname string) *OAuth2 {
return &OAuth2{
cfg: &clientcredentials.Config{
ClientID: clientId,
ClientSecret: clientSecret,
TokenURL: fmt.Sprintf("https://accounts.cloud.databricks.com/oidc/accounts/%s/v1/token", accId),
TokenURL: fmt.Sprintf("https://accounts.%s/oidc/accounts/%s/v1/token", hostname, accId),
Scopes: []string{"all-apis"},
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/databricks/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewClient(ctx context.Context, httpClient *http.Client, hostname, accountHo
}

if accountHostname == "" {
accountHostname = "accounts." + defaultHost
accountHostname = "accounts." + hostname
}
accountBaseUrl := &url.URL{
Scheme: "https",
Expand Down
Loading