Skip to content

Commit

Permalink
Add option to configure the location of the bricks CLI (#330)
Browse files Browse the repository at this point in the history
Especially for the VS Code extension this is easier and more robust than
messing the the `PATH`
  • Loading branch information
fjakobs authored Mar 8, 2023
1 parent 7e78ad1 commit 049d955
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit 049d955

Please sign in to comment.