databricks-cli/cmd
Pieter Noordhuis 4ccc70aeac
Consolidate environment variable interaction (#747)
## Changes

There are a couple places throughout the code base where interaction
with environment variables takes place. Moreover, more than one of these
would try to read a value from more than one environment variable as
fallback (for backwards compatibility). This change consolidates those
accesses.

The majority of diffs in this change are mechanical (i.e. add an
argument or replace a call).

This change:
* Moves common environment variable lookups for bundles to
`bundles/env`.
* Adds a `libs/env` package that wraps `os.LookupEnv` and `os.Getenv`
and allows for overrides to take place in a `context.Context`. By
scoping overrides to a `context.Context` we can avoid `t.Setenv` in
testing and unlock parallel test execution for integration tests.
* Updates call sites to pass through a `context.Context` where needed.
* For bundles, introduces `DATABRICKS_BUNDLE_ROOT` as new primary
variable instead of `BUNDLE_ROOT`. This was the last environment
variable that did not use the `DATABRICKS_` prefix.

## Tests

Unit tests pass.
2023-09-11 08:18:43 +00:00
..
account Update Go SDK to v0.19.0 (#729) 2023-09-05 09:43:57 +00:00
api Update Go SDK to v0.19.0 (#729) 2023-09-05 09:43:57 +00:00
auth Always resolve .databrickscfg file (#659) 2023-08-14 12:45:08 +00:00
bundle Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
configure Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
fs Remove dependency on global state for remaining commands (#613) 2023-07-27 10:03:08 +00:00
root Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
sync Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
version Added description for version command (#737) 2023-09-06 08:41:47 +00:00
workspace Update Go SDK to v0.19.0 (#729) 2023-09-05 09:43:57 +00:00
cmd.go Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00