databricks-cli/libs/dyn
Pieter Noordhuis 87dd46a3f8
Use dynamic configuration model in bundles (#1098)
## Changes

This is a fundamental change to how we load and process bundle
configuration. We now depend on the configuration being represented as a
`dyn.Value`. This representation is functionally equivalent to Go's
`any` (it is variadic) and allows us to capture metadata associated with
a value, such as where it was defined (e.g. file, line, and column). It
also allows us to represent Go's zero values properly (e.g. empty
string, integer equal to 0, or boolean false).

Using this representation allows us to let the configuration model
deviate from the typed structure we have been relying on so far
(`config.Root`). We need to deviate from these types when using
variables for fields that are not a string themselves. For example,
using `${var.num_workers}` for an integer `workers` field was impossible
until now (though not implemented in this change).

The loader for a `dyn.Value` includes functionality to capture any and
all type mismatches between the user-defined configuration and the
expected types. These mismatches can be surfaced as validation errors in
future PRs.

Given that many mutators expect the typed struct to be the source of
truth, this change converts between the dynamic representation and the
typed representation on mutator entry and exit. Existing mutators can
continue to modify the typed representation and these modifications are
reflected in the dynamic representation (see `MarkMutatorEntry` and
`MarkMutatorExit` in `bundle/config/root.go`).

Required changes included in this change:
* The existing interpolation package is removed in favor of
`libs/dyn/dynvar`.
* Functionality to merge job clusters, job tasks, and pipeline clusters
are now all broken out into their own mutators.

To be implemented later:
* Allow variable references for non-string types.
* Surface diagnostics about the configuration provided by the user in
the validation output.
* Some mutators use a resource's configuration file path to resolve
related relative paths. These depend on `bundle/config/paths.Path` being
set and populated through `ConfigureConfigFilePath`. Instead, they
should interact with the dynamically typed configuration directly. Doing
this also unlocks being able to differentiate different base paths used
within a job (e.g. a task override with a relative path defined in a
directory other than the base job).

## Tests

* Existing unit tests pass (some have been modified to accommodate)
* Integration tests pass
2024-02-16 19:41:58 +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 Add functionality to visit values in `dyn.Value` tree (#1142) 2024-01-24 18:38:46 +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