databricks-cli/libs/dyn
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
..
convert Avoid infinite recursion when normalizing a recursive type (#1213) 2024-02-16 12:56:02 +00:00
dynvar Fix issue where interpolating a new ref would rewrite unrelated fields (#1217) 2024-02-16 16:19:40 +00:00
merge Use dynamic configuration model in bundles (#1098) 2024-02-16 19:41:58 +00:00
yamlloader Rename libs/config -> libs/dyn (#1086) 2023-12-22 13:20:45 +00:00
yamlsaver Generate correct YAML if custom_tags or spark_conf is used for pipeline or job cluster configuration (#1210) 2024-02-15 15:03:19 +00:00
kind.go Define constant for the invalid `dyn.Value` (#1101) 2024-01-05 13:02:04 +00:00
kind_test.go Define constant for the invalid `dyn.Value` (#1101) 2024-01-05 13:02:04 +00:00
location.go Rename libs/config -> libs/dyn (#1086) 2023-12-22 13:20:45 +00:00
location_test.go Rename libs/config -> libs/dyn (#1086) 2023-12-22 13:20:45 +00:00
path.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
path_string.go Rename libs/config -> libs/dyn (#1086) 2023-12-22 13:20:45 +00:00
path_string_test.go Rename libs/config -> libs/dyn (#1086) 2023-12-22 13:20:45 +00:00
path_test.go Rename libs/config -> libs/dyn (#1086) 2023-12-22 13:20:45 +00:00
value.go Use dynamic configuration model in bundles (#1098) 2024-02-16 19:41:58 +00:00
value_test.go Define constant for the invalid `dyn.Value` (#1101) 2024-01-05 13:02:04 +00:00
value_underlying.go Consolidate functions to convert `dyn.Value` to native types (#1100) 2024-01-05 12:06:12 +00:00
value_underlying_test.go Consolidate functions to convert `dyn.Value` to native types (#1100) 2024-01-05 12:06:12 +00:00
visit.go Add functionality to visit values in `dyn.Value` tree (#1142) 2024-01-24 18:38:46 +00:00
visit_get.go Add functionality to visit values in `dyn.Value` tree (#1142) 2024-01-24 18:38:46 +00:00
visit_get_test.go Add functionality to visit values in `dyn.Value` tree (#1142) 2024-01-24 18:38:46 +00:00
visit_map.go Add functionality to visit values in `dyn.Value` tree (#1142) 2024-01-24 18:38:46 +00:00
visit_map_test.go Harden `dyn.Value` equality check (#1173) 2024-02-05 16:54:41 +00:00
visit_set.go Add functionality to visit values in `dyn.Value` tree (#1142) 2024-01-24 18:38:46 +00:00
visit_set_test.go Add functionality to visit values in `dyn.Value` tree (#1142) 2024-01-24 18:38:46 +00:00
walk.go Rename libs/config -> libs/dyn (#1086) 2023-12-22 13:20:45 +00:00
walk_test.go Rename libs/config -> libs/dyn (#1086) 2023-12-22 13:20:45 +00:00