databricks-cli/bundle
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
..
artifacts Apply Python wheel trampoline if workspace library is used (#755) 2023-09-08 13:45:21 +00:00
config Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
deploy Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
deployer Fix locker unlock for destroy (#492) 2023-06-19 15:57:25 +02:00
env Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
internal/tf Update Terraform provider schema structs from 1.23.0 (#713) 2023-08-30 13:58:28 +00:00
libraries Apply Python wheel trampoline if workspace library is used (#755) 2023-09-08 13:45:21 +00:00
phases Added transformation mutator for Python wheel task for them to work on DBR <13.1 (#635) 2023-08-30 12:21:39 +00:00
python Apply Python wheel trampoline if workspace library is used (#755) 2023-09-08 13:45:21 +00:00
run Do not include empty output in job run output (#749) 2023-09-08 09:52:45 +00:00
schema Make bundle and sync fields optional (#757) 2023-09-11 08:16:22 +00:00
tests List available targets when incorrect target passed (#756) 2023-09-08 15:37:55 +00:00
bundle.go Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
bundle_test.go Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
context.go Make sync command work in bundle context; reorder args (#207) 2023-02-20 11:33:30 +01:00
context_test.go Add command that writes the materialized bundle configuration to stdout (#95) 2022-11-21 15:39:53 +01:00
deferred.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
deferred_test.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
mutator.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
mutator_test.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
root.go Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
root_test.go Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
seq.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00
seq_test.go Added support for bundle.Seq, simplified Mutator.Apply interface (#403) 2023-05-24 14:45:19 +02:00