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

login command ignores DATABRICKS_CONFIG_FILE env var and fails in absence of ~/.databrickscfg #655

Closed
BenPhegan opened this issue Aug 11, 2023 · 1 comment · Fixed by #659

Comments

@BenPhegan
Copy link

As part of this change #629 an explicit call to databrickscfg.DefaultPath is used rather than checking for the env var DATABRICKS_CONFIG_FILE as per

configFile := os.Getenv("DATABRICKS_CONFIG_FILE")

This causes a hard error that prevents any further execution if there is NOT a file called ~/.databrickscfg, regardless of the DATABRICKS_CONFIG_FILE setting.

This is also explicitly used here:

_, profiles, err := LoadProfiles(DefaultPath, MatchAllProfiles)

Is there a better way to guard the use of this config default so that DATABRICKS_CONFIG_FILE is used if set regardless of which code path is run?

@mgyucht
Copy link
Contributor

mgyucht commented Aug 14, 2023

Thanks for raising this, my mistake. I believe I've cleaned this up in the linked PR sufficiently to prevent this class of issue from recurring.

github-merge-queue bot pushed a commit that referenced this issue Aug 14, 2023
## Changes
#629 introduced a change to autopopulate the host from .databrickscfg if
the user is logging back into a host they were previously using. This
did not respect the DATABRICKS_CONFIG_FILE env variable, causing the
flow to stop working for users with no .databrickscfg file in their home
directory.

This PR refactors all config file loading to go through one interface,
`databrickscfg.GetDatabricksCfg()`, and an auxiliary
`databrickscfg.GetDatabricksCfgPath()` to get the configured file path.

Closes #655.

## Tests
```
$ databricks auth login --profile abc
Error: open /Users/miles/.databrickscfg: no such file or directory

$ ./cli auth login --profile abc
Error: cannot load Databricks config file: open /Users/miles/.databrickscfg: no such file or directory


$ DATABRICKS_CONFIG_FILE=~/.databrickscfg.bak ./cli auth login --profile abc
Databricks Host: https://asdf
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants