Skip to content

Commit ed445cb

Browse files
authored
Fixed auth login ignoring DATABRICKS_CONFIG_FILE environmental variable when saving profile (#3266)
## Changes Fixed auth login ignoring DATABRICKS_CONFIG_FILE environmental variable when saving profile ## Why Fixes #1971 ## Tests Added acceptance regression test. Removed the tests here because OAuth flow requires a browser and does not currently work on GH runners 2f8c4a6 The test passed locally though <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent efc176a commit ed445cb

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
### Dependency updates
88

99
### CLI
10+
* Fixed auth login ignoring DATABRICKS_CONFIG_FILE environmental variable when saving profile ([#3266](https://github.com/databricks/cli/pull/3266))
1011

1112
### Bundles
1213

cmd/auth/login.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"os"
78
"runtime"
89
"strings"
910
"time"
@@ -140,6 +141,10 @@ depends on the existing profiles you have set in your configuration file
140141
AuthType: "databricks-cli",
141142
ClusterID: clusterID,
142143
}
144+
databricksCfgFile := os.Getenv("DATABRICKS_CONFIG_FILE")
145+
if databricksCfgFile != "" {
146+
cfg.ConfigFile = databricksCfgFile
147+
}
143148

144149
ctx, cancel := context.WithTimeout(ctx, loginTimeout)
145150
defer cancel()
@@ -164,11 +169,12 @@ depends on the existing profiles you have set in your configuration file
164169

165170
if profileName != "" {
166171
err = databrickscfg.SaveToProfile(ctx, &config.Config{
167-
Profile: profileName,
168-
Host: cfg.Host,
169-
AuthType: cfg.AuthType,
170-
AccountID: cfg.AccountID,
171-
ClusterID: cfg.ClusterID,
172+
Profile: profileName,
173+
Host: cfg.Host,
174+
AuthType: cfg.AuthType,
175+
AccountID: cfg.AccountID,
176+
ClusterID: cfg.ClusterID,
177+
ConfigFile: cfg.ConfigFile,
172178
})
173179
if err != nil {
174180
return err

0 commit comments

Comments
 (0)