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

Add option to configure the location of the bricks CLI #330

Merged
merged 1 commit into from
Mar 8, 2023
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
9 changes: 8 additions & 1 deletion config/auth_u2m.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,17 @@ type bricksCliTokenSource struct {

func (ts *bricksCliTokenSource) Token() (*oauth2.Token, error) {
what := []string{"auth", "token", "--host", ts.cfg.Host}

if ts.cfg.IsAccountClient() {
what = append(what, "--account-id", ts.cfg.AccountID)
}
out, err := exec.Command("bricks", what...).Output()

bricksCli := ts.cfg.BricksCliPath
if bricksCli == "" {
bricksCli = "bricks"
}

out, err := exec.Command(bricksCli, what...).Output()
if ee, ok := err.(*exec.ExitError); ok {
return nil, fmt.Errorf("cannot get access token: %s", string(ee.Stderr))
}
Expand Down
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ type Config struct {
ClientID string `name:"client_id" env:"DATABRICKS_CLIENT_ID" auth:"oauth"`
ClientSecret string `name:"client_secret" env:"DATABRICKS_CLIENT_SECRET" auth:"oauth,sensitive"`

// Path to the 'bricks' CLI
BricksCliPath string `name:"bricks_cli_path" env:"BRICKS_CLI_PATH"`

// When multiple auth attributes are available in the environment, use the auth type
// specified by this argument. This argument also holds currently selected auth.
AuthType string `name:"auth_type" env:"DATABRICKS_AUTH_TYPE" auth:"-"`
Expand Down