-
Notifications
You must be signed in to change notification settings - Fork 149
direct: Fix permissions state path to match input config schema #4703
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
Changes from all commits
f6f0d31
c8a9e5c
a423c1e
089debc
e3063b4
45b25d4
0fa70ab
a079c18
c734b34
6b510f5
cd98785
cf33a6c
40bfd97
c45c8d4
4c65311
eb831ad
858f6dd
aaab916
c8846db
fa1dc33
35142e2
6eddc56
82fda0e
9c71363
2138f66
b2fe80b
050d9c1
6fa0192
99a215c
7fed34f
3bafc16
a8de2cf
c07f196
87f4424
1f9ef86
88d8282
f5c0ef8
ee35420
3130008
7a530c9
8b5b6bd
eab7338
77665e0
53cf2b3
07d255c
ffd621a
55772fc
9c95415
c7e41d6
38316f8
8bc1468
83a2044
daca030
5060b7d
6b1d59f
45ef725
1ef280e
28dd02f
f78698b
5b991fa
5308fa2
6a36204
a7e650a
ebb6624
716d1a3
bde5897
74b0f02
669297b
1807c08
38e0d84
547318f
8de06ad
00267b5
60ae21e
1eeee9b
c1ed8cc
23afaa6
a122632
e71d844
f1d93a8
ecfd4cf
314b70d
56f4311
e80aca2
41f54e6
50090e4
4f681e9
3c15b24
67c3474
a8bfb73
8b402e0
051b54a
79d09ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| true |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,5 @@ | ||
| # Direct engine error: cannot plan resources.jobs.my_job.permissions: cannot update | ||
| # [0].service_principal_name: failed to navigate to parent [0]: [0]: cannot index struct. | ||
| # This is a bug in structaccess.Set() where it fails to index into a struct when | ||
| # setting permissions with service_principal_name. | ||
| # See https://github.com/databricks/cli/pull/4644 | ||
| Badness = "Direct engine fails to plan permissions with service_principal_name on jobs" | ||
| Cloud = true | ||
| RecordRequests = false | ||
|
|
||
| [EnvMatrix] | ||
| DATABRICKS_BUNDLE_ENGINE = ["terraform"] | ||
| DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "state_version": 1, | ||
| "state_version": 2, | ||
| "cli_version": "[DEV_VERSION]", | ||
| "lineage": "[UUID]", | ||
| "serial": 2, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| bundle: | ||
| name: test-bundle-$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| jobs: | ||
| # job_src defines permissions and a tag value used as references by other resources | ||
| job_src: | ||
| name: test-job-src-$UNIQUE_NAME | ||
| tags: | ||
| perm_group: users | ||
| permissions: | ||
| - level: CAN_VIEW | ||
| group_name: users | ||
|
|
||
| # job_perm_ref uses permission fields from job_src as its permission values | ||
| job_perm_ref: | ||
| name: test-job-perm-ref-$UNIQUE_NAME | ||
| permissions: | ||
| - level: ${resources.jobs.job_src.permissions[0].level} | ||
| group_name: ${resources.jobs.job_src.permissions[0].group_name} | ||
|
|
||
| # job_tag_ref uses a job tag from job_src as a permission group_name | ||
| job_tag_ref: | ||
| name: test-job-tag-ref-$UNIQUE_NAME | ||
| permissions: | ||
| - level: CAN_VIEW | ||
| group_name: ${resources.jobs.job_src.tags.perm_group} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| bundle: | ||
| name: test-bundle-$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| jobs: | ||
| job_b: | ||
| name: test-job-b-$UNIQUE_NAME | ||
| permissions: | ||
| - level: CAN_VIEW | ||
| group_name: users | ||
| - level: CAN_MANAGE | ||
| group_name: admins | ||
|
|
||
| job_a: | ||
| name: test-job-a-$UNIQUE_NAME | ||
| permissions: | ||
| # Reference level and group_name from job_b by index | ||
| - level: ${resources.jobs.job_b.permissions[0].level} | ||
| group_name: ${resources.jobs.job_b.permissions[0].group_name} | ||
| - level: ${resources.jobs.job_b.permissions[1].level} | ||
| group_name: ${resources.jobs.job_b.permissions[1].group_name} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| bundle: | ||
| name: test-bundle-$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| jobs: | ||
| foo: | ||
| name: test-job-$UNIQUE_NAME | ||
| permissions: | ||
| - level: CAN_VIEW | ||
| group_name: users |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
|
|
||
| >>> [CLI_293] --version | ||
| Databricks CLI v0.293.0 | ||
| INPUT_CONFIG_OK |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Invariant to test: current CLI can deploy on top of state produced by v0.293.0 | ||
|
|
||
| cp -r "$TESTDIR/../data/." . &> LOG.cp | ||
|
|
||
| INIT_SCRIPT="$TESTDIR/../configs/$INPUT_CONFIG-init.sh" | ||
| if [ -f "$INIT_SCRIPT" ]; then | ||
| source "$INIT_SCRIPT" &> LOG.init | ||
| fi | ||
|
|
||
| envsubst < "$TESTDIR/../configs/$INPUT_CONFIG" > databricks.yml | ||
|
|
||
| cleanup() { | ||
| $CLI bundle destroy --auto-approve &> LOG.destroy | ||
| cat LOG.destroy | contains.py '!panic' '!internal error' > /dev/null | ||
|
|
||
| CLEANUP_SCRIPT="$TESTDIR/../configs/$INPUT_CONFIG-cleanup.sh" | ||
| if [ -f "$CLEANUP_SCRIPT" ]; then | ||
| source "$CLEANUP_SCRIPT" &> LOG.cleanup | ||
| fi | ||
| } | ||
|
|
||
| trap cleanup EXIT | ||
|
|
||
| # Deploy with old CLI to produce v0.293.0 state | ||
| trace $CLI_293 --version | ||
| $CLI_293 bundle deploy &> LOG.deploy.293 | ||
| cat LOG.deploy.293 | contains.py '!panic' '!internal error' > /dev/null | ||
|
|
||
| echo INPUT_CONFIG_OK | ||
|
|
||
| # Deploy with current CLI on top of old state | ||
| $CLI bundle deploy &> LOG.deploy | ||
| cat LOG.deploy | contains.py '!panic' '!internal error' > /dev/null | ||
|
|
||
| # Verify no drift after current CLI deploy | ||
| $CLI bundle plan -o json > LOG.planjson 2>LOG.planjson.err | ||
| cat LOG.planjson.err | contains.py '!panic' '!internal error' > /dev/null | ||
| verify_no_drift.py LOG.planjson | ||
|
|
||
| $CLI bundle plan 2>LOG.plan.err | contains.py '!panic' '!internal error' 'Plan: 0 to add, 0 to change, 0 to delete' > LOG.plan | ||
| cat LOG.plan.err | contains.py '!panic' '!internal error' > /dev/null |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Cloud = false | ||
| Slow = true | ||
|
|
||
| # Cross-resource permission references (${resources.jobs.X.permissions[N].field}) require | ||
| # permissions to be part of the job schema, which was added after v0.293.0. | ||
| EnvMatrixExclude.no_permission_ref = ["INPUT_CONFIG=job_permission_ref.yml.tmpl"] | ||
| EnvMatrixExclude.no_cross_resource_ref = ["INPUT_CONFIG=job_cross_resource_ref.yml.tmpl"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "state_version": 1, | ||
| "state_version": 2, | ||
| "cli_version": "[DEV_VERSION]", | ||
| "lineage": "[UUID]", | ||
| "serial": 6, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "state_version": 1, | ||
| "state_version": 2, | ||
| "cli_version": "[DEV_VERSION]", | ||
| "lineage": "[UUID]", | ||
| "serial": 3, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "state_version": 1, | ||
| "state_version": 2, | ||
| "cli_version": "[DEV_VERSION]", | ||
| "lineage": "[UUID]", | ||
| "serial": 5, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "state_version": 1, | ||
| "state_version": 2, | ||
| "cli_version": "[DEV_VERSION]", | ||
| "lineage": "[UUID]", | ||
| "serial": 9, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea but also comes at a cost.
E.g. I run in fresh worktrees all the time this would download all the time. I wonder if we can make this optional per test, so if you're working on something that doesn't need to perform a backward compat check or upgrade check you don't have to download this binary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could store that cache in ~/.databricks-cli-tests-cache to help with this (as a follow up).