databricks-cli/bundle/deploy/terraform
Pieter Noordhuis f70ec359dc
Use `dyn.Value` as input to generating Terraform JSON (#1218)
## Changes

This builds on #1098 and uses the `dyn.Value` representation of the
bundle configuration to generate the Terraform JSON definition of
resources in the bundle.

The existing code (in `BundleToTerraform`) was not great and in an
effort to slightly improve this, I added a package `tfdyn` that includes
dedicated files for each resource type. Every resource type has its own
conversion type that takes the `dyn.Value` of the bundle-side resource
and converts it into Terraform resources (e.g. a job and optionally its
permissions).

Because we now use a `dyn.Value` as input, we can represent and emit
zero-values that have so far been omitted. For example, setting
`num_workers: 0` in your bundle configuration now propagates all the way
to the Terraform JSON definition.

## Tests

* Unit tests for every converter. I reused the test inputs from
`convert_test.go`.
* Equivalence tests in every existing test case checks that the
resulting JSON is identical.
* I manually compared the TF JSON file generated by the CLI from the
main branch and from this PR on all of our bundles and bundle examples
(internal and external) and found the output doesn't change (with the
exception of the odd zero-value being included by the version in this
PR).
2024-02-16 20:54:38 +00:00
..
tfdyn Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
apply.go Tune output of bundle deploy command (#1047) 2023-12-21 08:00:37 +00:00
convert.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_test.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +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
filer.go Correctly overwrite local state if remote state is newer (#1008) 2023-11-24 11:15:46 +00:00
import.go Added `bundle deployment bind` and `unbind` command (#1131) 2024-02-14 18:04:45 +00:00
init.go Pass `USERPROFILE` environment variable to Terraform (#1001) 2023-11-22 09:16:28 +00:00
init_test.go Pass `USERPROFILE` environment variable to Terraform (#1001) 2023-11-22 09:16:28 +00:00
interpolate.go Use dynamic configuration model in bundles (#1098) 2024-02-16 19:41:58 +00:00
interpolate_test.go Use dynamic configuration model in bundles (#1098) 2024-02-16 19:41:58 +00:00
load.go Fix metadata computation for empty bundle (#939) 2023-11-02 11:00:30 +00:00
load_test.go Fix metadata computation for empty bundle (#939) 2023-11-02 11:00:30 +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 Correctly overwrite local state if remote state is newer (#1008) 2023-11-24 11:15:46 +00:00
state_pull_test.go Use mockery to generate mocks compatible with testify/mock (#1190) 2024-02-08 15:18:53 +00:00
state_push.go Tune output of bundle deploy command (#1047) 2023-12-21 08:00:37 +00:00
state_push_test.go Use mockery to generate mocks compatible with testify/mock (#1190) 2024-02-08 15:18:53 +00:00
state_test.go Correctly overwrite local state if remote state is newer (#1008) 2023-11-24 11:15:46 +00:00
unbind.go Added `bundle deployment bind` and `unbind` command (#1131) 2024-02-14 18:04:45 +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 Correctly overwrite local state if remote state is newer (#1008) 2023-11-24 11:15:46 +00:00
write.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00