databricks-cli/bundle/deploy/terraform
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
..
apply.go databricks bundle init template v2: optional stubs, DLT support (#700) 2023-09-06 09:52:31 +00:00
convert.go Support Model Serving Endpoints in bundles (#682) 2023-09-07 21:54:31 +00:00
convert_test.go Support Model Serving Endpoints in bundles (#682) 2023-09-07 21:54:31 +00:00
destroy.go Use custom prompter for bundle template inputs (#663) 2023-08-15 14:50:20 +00:00
dir.go Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
init.go Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
init_test.go Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
interpolate.go Support Model Serving Endpoints in bundles (#682) 2023-09-07 21:54:31 +00:00
load.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
load_test.go Renamed `environments` to `targets` in bundle configuration (#670) 2023-08-17 15:22:32 +00:00
pkg.go Add mutators to pull and push Terraform state (#288) 2023-03-30 12:01:09 +02:00
plan.go Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
state_pull.go Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
state_push.go Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
util.go Do not truncate local state file when pulling remote changes (#382) 2023-05-16 17:02:33 +02:00
util_test.go Do not truncate local state file when pulling remote changes (#382) 2023-05-16 17:02:33 +02:00
write.go Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00