databricks-cli/libs/databrickscfg
Miles Yucht 5b819cd982
Always resolve .databrickscfg file (#659)
## 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
```
2023-08-14 12:45:08 +00:00
..
testdata Add profile on `databricks auth login` (#423) 2023-06-02 13:49:39 +02:00
host.go Try to resolve a profile if only the host is specified (#287) 2023-03-29 20:44:19 +02:00
host_test.go Try to resolve a profile if only the host is specified (#287) 2023-03-29 20:44:19 +02:00
loader.go Correctly use --profile flag passed for all bundle commands (#571) 2023-07-12 14:09:25 +02:00
loader_test.go Add profile on `databricks auth login` (#423) 2023-06-02 13:49:39 +02:00
ops.go Correctly use --profile flag passed for all bundle commands (#571) 2023-07-12 14:09:25 +02:00
ops_test.go Include [DEFAULT] section header when writing ~/.databrickscfg (#464) 2023-06-13 16:41:56 +00:00
profiles.go Always resolve .databrickscfg file (#659) 2023-08-14 12:45:08 +00:00
profiles_test.go Always resolve .databrickscfg file (#659) 2023-08-14 12:45:08 +00:00