Repository navigation
Fix target variable overrides dropped under environments #8183
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
Open
denik
wants to merge
10
commits into
main
Choose a base branch
from
denik/fix-environments-var-shorthand
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+300
−29
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
aeb79fd
Apply short-form variable overrides under environments
denik e1072d8
Harden target variable shorthand rewriting
denik 97235b2
Link the changelog entry to #8183
denik 41cf195
Keep metadata-only overrides of complex variables under environments
denik 37d2398
acc: normalize Windows path separators in target_override_shorthand_s…
denik 9a0bef0
acc: match single backslashes in target_override_shorthand_shapes
denik 449d826
Keep invalid targets values an error, at its location
denik 4422e29
Satisfy exhaustive lint and the changelog link format
denik f8ef767
acc: replace errcode with musterr in target_override_shorthand_shapes
denik 97ee686
Address review: value overrides, test layout, legacy classifier tests
denik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * Fix target variable overrides being dropped with a warning, so the root value was used: short-form and complex-value overrides under the deprecated `environments` key, and unquoted dates under `targets`. Short-form overrides under `environments` of a variable that is not defined now fail with `variable x is not defined but is assigned a value`, as they already did under `targets`. A target override no longer panics when the variable's `type` is not a string, and a scalar `targets` value (such as `targets: false`) is reported at its location instead of failing with `failed to rewrite`. ([#8183](https://github.com/databricks/cli/pull/8183)) |
2 changes: 2 additions & 0 deletions
2
...e/bundle/validate/targets/scalar_rewrite_diagnostic/malformed-environments/databricks.yml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| bundle: {name: shapes} | ||
| environments: {dev: {}, old: {variables: oops}} |
2 changes: 2 additions & 0 deletions
2
...ptance/bundle/validate/targets/scalar_rewrite_diagnostic/malformed-targets/databricks.yml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| bundle: {name: shapes} | ||
| targets: {dev: {}, old: {variables: oops}} |
44 changes: 43 additions & 1 deletion
44
acceptance/bundle/validate/targets/scalar_rewrite_diagnostic/output.txt
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,48 @@ | ||
|
|
||
| >>> [CLI] bundle validate | ||
| Error: failed to rewrite [TEST_TMP_DIR]/databricks.yml: expected a map or sequence, found bool | ||
| Error: expected map, found bool | ||
| at targets | ||
| in databricks.yml:4:10 | ||
|
|
||
|
|
||
| Found 1 error | ||
|
|
||
| === malformed-targets | ||
|
|
||
| >>> [CLI] bundle validate -t dev | ||
| Error: failed to rewrite [TEST_TMP_DIR]/malformed-targets/databricks.yml: expected a map or sequence, found string | ||
|
|
||
|
|
||
| Found 1 error | ||
|
|
||
| === malformed-environments | ||
|
|
||
| >>> [CLI] bundle validate -t dev | ||
| Warning: expected map, found string | ||
| at environments.old.variables | ||
| in databricks.yml:2:42 | ||
|
|
||
| Name: shapes | ||
| Target: dev | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/shapes/dev | ||
|
|
||
| Found 1 warning | ||
|
|
||
| === sequence-targets | ||
|
|
||
| >>> [CLI] bundle validate -t dev | ||
| Error: failed to rewrite [TEST_TMP_DIR]/sequence-targets/databricks.yml: expected a map or sequence, found string | ||
|
|
||
|
|
||
| Found 1 error | ||
|
|
||
| === toplevel | ||
|
|
||
| >>> [CLI] bundle validate -o json -t dev | ||
| Warning: expected map, found bool | ||
| at environments | ||
| in databricks.yml:3:15 | ||
|
|
||
| json.variables.x.value = "target_value"; |
15 changes: 14 additions & 1 deletion
15
acceptance/bundle/validate/targets/scalar_rewrite_diagnostic/script
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,15 @@ | ||
| # A scalar targets section is an error. | ||
| # A scalar targets section is an error at its location. | ||
| musterr trace $CLI bundle validate | ||
|
|
||
| # A malformed variables block in another target: an error under targets (also in a sequence), | ||
| # a warning under environments, as before. | ||
| title malformed-targets | ||
| withdir malformed-targets musterr trace $CLI bundle validate -t dev | ||
| title malformed-environments | ||
| withdir malformed-environments trace $CLI bundle validate -t dev | ||
| title sequence-targets | ||
| withdir sequence-targets musterr trace $CLI bundle validate -t dev | ||
|
|
||
| # environments that is not a map, next to targets: a warning, and the targets override applies. | ||
| title toplevel | ||
| withdir toplevel trace $CLI bundle validate -o json -t dev | gron.py | grep '^json\.variables\..*\.value' |
2 changes: 2 additions & 0 deletions
2
acceptance/bundle/validate/targets/scalar_rewrite_diagnostic/sequence-targets/databricks.yml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| bundle: {name: shapes} | ||
| targets: [{variables: oops}] |
8 changes: 7 additions & 1 deletion
8
acceptance/bundle/validate/targets/scalar_rewrite_diagnostic/test.toml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,7 @@ | ||
| Badness = 'The error names an internal step ("failed to rewrite") and has no location, instead of reporting a type error at targets.' | ||
| # Cases in subdirectories leave .databricks there. | ||
| Ignore = [".databricks"] | ||
|
|
||
| # Windows prints the config path with backslashes in the rewrite error. | ||
| [[Repls]] | ||
| Old = '\\' | ||
| New = '/' |
4 changes: 4 additions & 0 deletions
4
acceptance/bundle/validate/targets/scalar_rewrite_diagnostic/toplevel/databricks.yml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| bundle: {name: shapes} | ||
| variables: {x: {default: root_value}} | ||
| environments: false | ||
| targets: {dev: {variables: {x: target_value}}} |
12 changes: 12 additions & 0 deletions
12
acceptance/bundle/validate/variables/target_timestamp_shorthand/environments/databricks.yml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| bundle: | ||
| name: test-bundle | ||
|
|
||
| variables: | ||
| x: | ||
| default: base | ||
|
|
||
| # "environments" is the deprecated name of "targets". | ||
| environments: | ||
| dev: | ||
| variables: | ||
| x: 2020-01-02 |
14 changes: 7 additions & 7 deletions
14
acceptance/bundle/validate/variables/target_timestamp_shorthand/output.txt
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
|
|
||
| >>> [CLI] bundle validate -t dev -o json | ||
| Warning: expected map, found time | ||
| at targets.dev.variables.x | ||
| in databricks.yml:11:10 | ||
| json.variables.x.default = "2020-01-02"; | ||
| json.variables.x.value = "2020-01-02"; | ||
|
|
||
| { | ||
| "default": "base", | ||
| "value": "base" | ||
| } | ||
| === environments | ||
|
|
||
| >>> [CLI] bundle validate -t dev -o json | ||
| json.variables.x.default = "2020-01-02"; | ||
| json.variables.x.value = "2020-01-02"; |
6 changes: 4 additions & 2 deletions
6
acceptance/bundle/validate/variables/target_timestamp_shorthand/script
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| # A timestamp as a target variable shorthand. | ||
| trace $CLI bundle validate -t dev -o json | jq .variables.x | ||
| # A timestamp as a target variable shorthand, under targets and under environments. | ||
| trace $CLI bundle validate -t dev -o json | gron.py | grep '^json\.variables\.x\.' | ||
| title environments | ||
| withdir environments trace $CLI bundle validate -t dev -o json | gron.py | grep '^json\.variables\.x\.' |
3 changes: 2 additions & 1 deletion
3
acceptance/bundle/validate/variables/target_timestamp_shorthand/test.toml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| Badness = 'The timestamp shorthand is dropped with "expected map, found time" instead of being used as the default.' | ||
| # The environments case leaves .databricks in its subdirectory. | ||
| Ignore = [".databricks"] |
17 changes: 17 additions & 0 deletions
17
acceptance/bundle/variables/environments_shorthand/full-form/databricks.yml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| bundle: {name: shapes} | ||
| variables: | ||
| with_sensitive: {default: root_value} | ||
| metadata_only: {default: root_value} | ||
| value_key: {default: root_value} | ||
| complex_with_sensitive: {type: complex, default: {workers: 1}} | ||
| complex_metadata_only: {type: complex, default: {workers: 1}} | ||
| complex_value_key: {type: complex, default: {workers: 1}} | ||
| environments: | ||
| dev: | ||
| variables: | ||
| with_sensitive: {default: target_value, sensitive: false} | ||
| metadata_only: {sensitive: false} | ||
| value_key: {value: target_value} | ||
| complex_with_sensitive: {default: {workers: 2}, sensitive: false} | ||
| complex_metadata_only: {sensitive: false} | ||
| complex_value_key: {value: {workers: 2}} |
18 changes: 11 additions & 7 deletions
18
acceptance/bundle/variables/environments_shorthand/output.txt
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,15 @@ | ||
|
|
||
| >>> [CLI] bundle validate -o json -t dev | ||
| Warning: expected map, found string | ||
| at environments.dev.variables.short | ||
| in databricks.yml:18:14 | ||
| json.variables.complex.value.key = "target_value"; | ||
| json.variables.full.value = "target_value"; | ||
| json.variables.short.value = "target_value"; | ||
|
|
||
| Warning: unknown field: key | ||
| at environments.dev.variables.complex | ||
| in databricks.yml:22:9 | ||
| === full-form | ||
|
|
||
| {"complex":{"key":"root_value"},"full":"target_value","short":"root_value"} | ||
| >>> [CLI] bundle validate -o json -t dev | ||
| json.variables.complex_metadata_only.value.workers = 1; | ||
| json.variables.complex_value_key.value.workers = 1; | ||
| json.variables.complex_with_sensitive.value.workers = 2; | ||
| json.variables.metadata_only.value = "root_value"; | ||
| json.variables.value_key.value = "root_value"; | ||
| json.variables.with_sensitive.value = "target_value"; |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| trace $CLI bundle validate -o json -t dev | jq -c '.variables | map_values(.value)' | ||
| trace $CLI bundle validate -o json -t dev | gron.py | grep '^json\.variables\..*\.value' | ||
|
|
||
| # Full-form overrides under environments keep what normalization applied to them before. | ||
| title full-form | ||
| withdir full-form trace $CLI bundle validate -o json -t dev | gron.py | grep '^json\.variables\..*\.value' |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| Badness = "Short-form target variable overrides under the deprecated 'environments' key (short and complex here) are dropped with a warning, so the root value is used instead of target_value. The same overrides under 'targets', or in the full form, work." | ||
| # The full-form case leaves .databricks in its subdirectory. | ||
| Ignore = [".databricks"] |
3 changes: 3 additions & 0 deletions
3
acceptance/bundle/variables/target_override_nonstring_type/environments/databricks.yml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| bundle: {name: shapes} | ||
| variables: {x: {type: 5, default: {a: 1}}} | ||
| environments: {dev: {variables: {x: {a: 2}}}} |
2 changes: 2 additions & 0 deletions
2
acceptance/bundle/variables/target_override_nonstring_type/out.test.toml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Cloud = false | ||
| EnvMatrix.DMS = ["", "true"] |
22 changes: 22 additions & 0 deletions
22
acceptance/bundle/variables/target_override_nonstring_type/output.txt
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
|
|
||
| === targets | ||
|
|
||
| >>> [CLI] bundle validate -o json -t dev | ||
| Warning: invalid value "5" for enum field. Valid values are [complex] | ||
| at variables.x.type | ||
| in databricks.yml:2:23 | ||
|
|
||
| json.variables.x.value.a = 2; | ||
|
|
||
| === environments | ||
|
|
||
| >>> [CLI] bundle validate -o json -t dev | ||
| Warning: unknown field: a | ||
| at environments.dev.variables.x | ||
| in databricks.yml:3:38 | ||
|
|
||
| Warning: invalid value "5" for enum field. Valid values are [complex] | ||
| at variables.x.type | ||
| in databricks.yml:2:23 | ||
|
|
||
| json.variables.x.value.a = 1; |
5 changes: 5 additions & 0 deletions
5
acceptance/bundle/variables/target_override_nonstring_type/script
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # A non-string variable type with a map override: normalization reports the type, no panic. | ||
| title targets | ||
| withdir targets trace $CLI bundle validate -o json -t dev | gron.py | grep '^json\.variables\..*\.value' | ||
| title environments | ||
| withdir environments trace $CLI bundle validate -o json -t dev | gron.py | grep '^json\.variables\..*\.value' |
3 changes: 3 additions & 0 deletions
3
acceptance/bundle/variables/target_override_nonstring_type/targets/databricks.yml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| bundle: {name: shapes} | ||
| variables: {x: {type: 5, default: {a: 1}}} | ||
| targets: {dev: {variables: {x: {a: 2}}}} |
2 changes: 2 additions & 0 deletions
2
acceptance/bundle/variables/target_override_nonstring_type/test.toml
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Each case leaves .databricks in its subdirectory. | ||
| Ignore = [".databricks"] |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.