-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functionality to visit values in dyn.Value
tree
#1142
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This change adds the following functions: * `dyn.Get(value, "foo.bar") -> (dyn.Value, error)` * `dyn.Set(value, "foo.bar", newValue) -> (dyn.Value, error)` * `dyn.Map(value, "foo.bar", func) -> (dyn.Value, error)` And equivalent functions that take a previously constructed `dyn.Path`: * `dyn.GetByPath(value, dyn.Path) -> (dyn.Value, error)` * `dyn.SetByPath(value, dyn.Path, newValue) -> (dyn.Value, error)` * `dyn.MapByPath(value, dyn.Path, func) -> (dyn.Value, error)` Whenever the "set" and "map" functions need to change a value, they return a new `dyn.Value` such that the input value is never changed.
andrewnester
approved these changes
Jan 24, 2024
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jan 24, 2024
…1143) ## Changes This is the `dyn` counterpart to the `bundle/config/interpolation` package. It relies on the paths in `${foo.bar}` being valid `dyn.Path` instances. It leverages `dyn.Walk` to get a complete picture of all variable references and uses `dyn.Get` to retrieve values pointed to by variable references. Depends on #1142. ## Tests Unit test coverage. I tried to mirror the tests from `bundle/config/interpolation` and added new ones where applicable (for example to test type retention of referenced values).
pietern
added a commit
that referenced
this pull request
Jan 25, 2024
CLI: * Prompt for account profile only for account-level command execution instead of during `databricks labs install` flow ([#1128](#1128)). * Bring back `--json` flag for workspace-conf set-status command ([#1151](#1151)). Bundles: * Set `run_as` permissions after variable interpolation ([#1141](#1141)). * Add functionality to visit values in `dyn.Value` tree ([#1142](#1142)). * Add `dynvar` package for variable resolution with a `dyn.Value` tree ([#1143](#1143)). * Add support for `anyOf` to `skip_prompt_if` ([#1133](#1133)). * Added `bundle generate pipeline` command ([#1139](#1139)). Internal: * Use MockWorkspaceClient from SDK instead of WithImpl mocking ([#1134](#1134)). Dependency updates: * Bump github.com/databricks/databricks-sdk-go from 0.29.0 to 0.29.1 ([#1137](#1137)). * Bump github.com/hashicorp/terraform-json from 0.20.0 to 0.21.0 ([#1138](#1138)). * Update actions/setup-go to v5 ([#1148](#1148)). * Update codecov/codecov-action to v3 ([#1149](#1149)). * Use latest patch release of Go toolchain ([#1152](#1152)).
Merged
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jan 25, 2024
CLI: * Prompt for account profile only for account-level command execution instead of during `databricks labs install` flow ([#1128](#1128)). * Bring back `--json` flag for workspace-conf set-status command ([#1151](#1151)). Bundles: * Set `run_as` permissions after variable interpolation ([#1141](#1141)). * Add functionality to visit values in `dyn.Value` tree ([#1142](#1142)). * Add `dynvar` package for variable resolution with a `dyn.Value` tree ([#1143](#1143)). * Add support for `anyOf` to `skip_prompt_if` ([#1133](#1133)). * Added `bundle generate pipeline` command ([#1139](#1139)). Internal: * Use MockWorkspaceClient from SDK instead of WithImpl mocking ([#1134](#1134)). Dependency updates: * Bump github.com/databricks/databricks-sdk-go from 0.29.0 to 0.29.1 ([#1137](#1137)). * Bump github.com/hashicorp/terraform-json from 0.20.0 to 0.21.0 ([#1138](#1138)). * Update actions/setup-go to v5 ([#1148](#1148)). * Update codecov/codecov-action to v3 ([#1149](#1149)). * Use latest patch release of Go toolchain ([#1152](#1152)).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
This change adds the following functions:
dyn.Get(value, "foo.bar") -> (dyn.Value, error)
dyn.Set(value, "foo.bar", newValue) -> (dyn.Value, error)
dyn.Map(value, "foo.bar", func) -> (dyn.Value, error)
And equivalent functions that take a previously constructed
dyn.Path
:dyn.GetByPath(value, dyn.Path) -> (dyn.Value, error)
dyn.SetByPath(value, dyn.Path, newValue) -> (dyn.Value, error)
dyn.MapByPath(value, dyn.Path, func) -> (dyn.Value, error)
Changes made by the "set" and "map" functions are never reflected in the input argument; they return new
dyn.Value
instances for all nodes in the path leading up to the changed value.Tests
New unit tests cover all critical paths.