databricks-cli/bundle/deploy/terraform/tfdyn
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.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_experiment.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_experiment_test.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_grants.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_grants_test.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_job.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_job_test.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_model.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_model_serving_endpoint.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_model_serving_endpoint_test.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_model_test.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_permissions.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_permissions_test.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_pipeline.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_pipeline_test.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_registered_model.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
convert_registered_model_test.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00
rename_keys.go Use `dyn.Value` as input to generating Terraform JSON (#1218) 2024-02-16 20:54:38 +00:00