databricks-cli/bundle/config
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
..
interpolation Upgraded Go version to 1.21 (#664) 2023-08-15 13:50:40 +00:00
mutator Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
paths Make resource and artifact paths in bundle config relative to config folder (#708) 2023-09-04 09:55:01 +00:00
resources Support Model Serving Endpoints in bundles (#682) 2023-09-07 21:54:31 +00:00
testdata First look for databricks.yml before falling back to bundle.yml (#580) 2023-07-18 12:16:34 +02:00
variable Renamed `environments` to `targets` in bundle configuration (#670) 2023-08-17 15:22:32 +00:00
artifact.go Apply Python wheel trampoline if workspace library is used (#755) 2023-09-08 13:45:21 +00:00
bundle.go Renamed `environments` to `targets` in bundle configuration (#670) 2023-08-17 15:22:32 +00:00
git.go Add validation for Git settings in bundles (#578) 2023-07-30 12:44:33 +00:00
lock.go Acquire lock prior to deploy (#270) 2023-03-22 16:37:26 +01:00
lock_test.go Acquire lock prior to deploy (#270) 2023-03-22 16:37:26 +01:00
resources.go Support Model Serving Endpoints in bundles (#682) 2023-09-07 21:54:31 +00:00
resources_test.go Make resource and artifact paths in bundle config relative to config folder (#708) 2023-09-04 09:55:01 +00:00
root.go Make bundle and sync fields optional (#757) 2023-09-11 08:16:22 +00:00
root_test.go Renamed `environments` to `targets` in bundle configuration (#670) 2023-08-17 15:22:32 +00:00
sync.go Make resource and artifact paths in bundle config relative to config folder (#708) 2023-09-04 09:55:01 +00:00
target.go Make resource and artifact paths in bundle config relative to config folder (#708) 2023-09-04 09:55:01 +00:00
workspace.go Renamed `environments` to `targets` in bundle configuration (#670) 2023-08-17 15:22:32 +00:00