databricks-cli/libs/dyn/dynvar
Pieter Noordhuis 26094f01a0
Define `dyn.Mapping` to represent maps (#1301)
## Changes

Before this change maps were stored as a regular Go map with string
keys. This didn't let us capture metadata (location information) for map
keys.

To address this, this change replaces the use of the regular Go map with
a dedicated type for a dynamic map. This type stores the `dyn.Value` for
both the key and the value. It uses a map to still allow O(1) lookups
and redirects those into a slice.

## Tests

* All existing unit tests pass (some with minor modifications due to
interface change).
* Equality assertions with `assert.Equal` no longer worked because the
new `dyn.Mapping` persists the order in which keys are set and is
therefore susceptible to map ordering issues. To fix this, I added a
`dynassert` package that forwards all assertions to `testify/assert` but
intercepts equality for `dyn.Value` arguments.
2024-03-25 11:01:09 +00:00
..
lookup.go Add `dynvar` package for variable resolution with a `dyn.Value` tree (#1143) 2024-01-24 18:49:06 +00:00
lookup_test.go Define `dyn.Mapping` to represent maps (#1301) 2024-03-25 11:01:09 +00:00
ref.go Allow use of variables references in primitive non-string fields (#1219) 2024-02-19 10:44:51 +00:00
ref_test.go Define `dyn.Mapping` to represent maps (#1301) 2024-03-25 11:01:09 +00:00
resolve.go Fix issue where interpolating a new ref would rewrite unrelated fields (#1217) 2024-02-16 16:19:40 +00:00
resolve_test.go Define `dyn.Mapping` to represent maps (#1301) 2024-03-25 11:01:09 +00:00