Skip to content

Commit 3d8db90

Browse files
Make auth profiles respect DATABRICKS_CLI_PATH env var (#4467)
## Changes Update the `auth profiles` command to always load the value of the `DATABRICKS_CLI_PATH` environment variable as it otherwise does not load any environment variables. ## Why databricks/databricks-sdk-go#1428 changed the `databricks-cli` auth type in the Go SDK to use the CLI to fetch tokens instead of touching the U2M token store itself. Because of this acceptance tests break when we try to bump the go sdk version in the CLI, as the CLI was not accessible in the test environment. This PR makes it accessible. ## Tests auth login acceptance tests should pass --------- Co-authored-by: Denis Bilenko <denis.bilenko@databricks.com>
1 parent ae892e5 commit 3d8db90

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

acceptance/cmd/auth/login/nominal/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Profile test was successfully saved
44

55
>>> [CLI] auth profiles
66
Name Host Valid
7-
test [DATABRICKS_URL] NO
7+
test [DATABRICKS_URL] YES

acceptance/cmd/auth/login/nominal/script

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ sethome "./home"
33
# Use a fake browser that performs a GET on the authorization URL
44
# and follows the redirect back to localhost.
55
export BROWSER="browser.py"
6-
export DATABRICKS_CLI_PATH=$CLI
76

87
trace $CLI auth login --host $DATABRICKS_HOST --profile test
98
trace $CLI auth profiles
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Badness = "databricks auth profiles should return yes for the test profile. There's something going wrong with CLI detection in the SDK which makes this flag it as a legacy CLI."
2-
31
Ignore = [
42
"home"
53
]

cmd/auth/profiles.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"io/fs"
8+
"os"
89
"sync"
910
"time"
1011

@@ -33,9 +34,10 @@ func (c *profileMetadata) IsEmpty() bool {
3334

3435
func (c *profileMetadata) Load(ctx context.Context, configFilePath string, skipValidate bool) {
3536
cfg := &config.Config{
36-
Loaders: []config.Loader{config.ConfigFile},
37-
ConfigFile: configFilePath,
38-
Profile: c.Name,
37+
Loaders: []config.Loader{config.ConfigFile},
38+
ConfigFile: configFilePath,
39+
Profile: c.Name,
40+
DatabricksCliPath: os.Getenv("DATABRICKS_CLI_PATH"),
3941
}
4042
_ = cfg.EnsureResolved()
4143
if cfg.IsAws() {

0 commit comments

Comments
 (0)