-
Notifications
You must be signed in to change notification settings - Fork 155
direct: grants: revoke removed principals + pass PlanEntry to DoUpdate #4824
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
410e5e5
direct: grants: Add removed-principal regression test
denik ea99b01
direct: grants: Simplify removed-principal regression test
denik 243b122
clean up test
denik e71ff37
add direct files
denik b9d1a0f
keep text plan only
denik 30aa515
direct: grants: Add removed-principal plan goldens
denik efc6519
direct: grants: Revoke removed principals
denik 8d93d2d
acceptance: add gron noindex option
denik 439218e
acceptance: inline grants normalization pipeline
denik 772c0cb
direct: grants: derive revokes from plan changes
denik 37d5555
direct: grants: trim review-only churn
denik 2672d59
direct: grants: inline trivial helpers
denik 51348de
clean up test
denik 06c891f
direct: grants: Add out-of-band principal drift test
denik 6204d43
acceptance: check in out-of-band grants payload
denik 3c22b64
acceptance: extend grants drift plan coverage
denik ce2d618
direct: grants: tolerate malformed diff paths
denik feb2fa5
acceptance: capture follow-up remove_principal plan
denik 7ba98c4
direct: pass *PlanEntry to DoUpdate instead of Changes
denik 5355d46
direct: grants: remove unnecessary slice copy in listGrants
denik 37835cc
update NEXT_CHANGELOG
denik 9da425b
acceptance: regenerate outputs for updated testserver
denik b1224ce
fix resources/schemas/update
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
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
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
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
12 changes: 12 additions & 0 deletions
12
acceptance/bundle/resources/grants/schemas/out_of_band_principal/databricks.yml.tmpl
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: schema-grants-out-of-band-principal-$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| schemas: | ||
| grants_schema: | ||
| name: schema_out_of_band_principal_$UNIQUE_NAME | ||
| catalog_name: main | ||
| grants: | ||
| - principal: $CURRENT_USER_NAME | ||
| privileges: | ||
| - CREATE_TABLE |
83 changes: 83 additions & 0 deletions
83
acceptance/bundle/resources/grants/schemas/out_of_band_principal/out.plan.direct.json
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,83 @@ | ||
| { | ||
| "plan_version": 2, | ||
| "cli_version": "[DEV_VERSION]", | ||
| "lineage": "[UUID]", | ||
| "serial": 1, | ||
| "plan": { | ||
| "resources.schemas.grants_schema": { | ||
| "action": "skip", | ||
| "remote_state": { | ||
| "browse_only": false, | ||
| "catalog_name": "main", | ||
| "catalog_type": "MANAGED_CATALOG", | ||
| "created_at": [UNIX_TIME_MILLIS][0], | ||
| "created_by": "[USERNAME]", | ||
| "effective_predictive_optimization_flag": { | ||
| "inherited_from_name": "deco-uc-prod-isolated-aws-us-east-1", | ||
| "inherited_from_type": "METASTORE", | ||
| "value": "ENABLE" | ||
| }, | ||
| "enable_predictive_optimization": "INHERIT", | ||
| "full_name": "main.schema_out_of_band_principal_[UNIQUE_NAME]", | ||
| "metastore_id": "[UUID]", | ||
| "name": "schema_out_of_band_principal_[UNIQUE_NAME]", | ||
| "owner": "[USERNAME]", | ||
| "schema_id": "[UUID]", | ||
| "updated_at": [UNIX_TIME_MILLIS][1], | ||
| "updated_by": "[USERNAME]" | ||
| } | ||
| }, | ||
| "resources.schemas.grants_schema.grants": { | ||
| "depends_on": [ | ||
| { | ||
| "node": "resources.schemas.grants_schema", | ||
| "label": "${resources.schemas.grants_schema.id}" | ||
| } | ||
| ], | ||
| "action": "update", | ||
| "new_state": { | ||
| "value": { | ||
| "securable_type": "schema", | ||
| "full_name": "main.schema_out_of_band_principal_[UNIQUE_NAME]", | ||
| "__embed__": [ | ||
| { | ||
| "principal": "[USERNAME]", | ||
| "privileges": [ | ||
| "CREATE_TABLE" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "remote_state": { | ||
| "securable_type": "schema", | ||
| "full_name": "main.schema_out_of_band_principal_[UNIQUE_NAME]", | ||
| "__embed__": [ | ||
| { | ||
| "principal": "[USERNAME]", | ||
| "privileges": [ | ||
| "CREATE_TABLE" | ||
| ] | ||
| }, | ||
| { | ||
| "principal": "deco-test-user@databricks.com", | ||
| "privileges": [ | ||
| "USE_SCHEMA" | ||
| ] | ||
| } | ||
| ] | ||
| }, | ||
| "changes": { | ||
| "[principal='deco-test-user@databricks.com']": { | ||
| "action": "update", | ||
| "remote": { | ||
| "principal": "deco-test-user@databricks.com", | ||
| "privileges": [ | ||
| "USE_SCHEMA" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
acceptance/bundle/resources/grants/schemas/out_of_band_principal/out.plan.terraform.json
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,11 @@ | ||
| { | ||
| "cli_version": "[DEV_VERSION]", | ||
| "plan": { | ||
| "resources.schemas.grants_schema": { | ||
| "action": "skip" | ||
| }, | ||
| "resources.schemas.grants_schema.grants": { | ||
| "action": "update" | ||
| } | ||
| } | ||
| } |
52 changes: 52 additions & 0 deletions
52
acceptance/bundle/resources/grants/schemas/out_of_band_principal/out.plan2.direct.json
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,52 @@ | ||
| { | ||
| "plan_version": 2, | ||
| "cli_version": "[DEV_VERSION]", | ||
| "lineage": "[UUID]", | ||
| "serial": 2, | ||
| "plan": { | ||
| "resources.schemas.grants_schema": { | ||
| "action": "skip", | ||
| "remote_state": { | ||
| "browse_only": false, | ||
| "catalog_name": "main", | ||
| "catalog_type": "MANAGED_CATALOG", | ||
| "created_at": [UNIX_TIME_MILLIS][0], | ||
| "created_by": "[USERNAME]", | ||
| "effective_predictive_optimization_flag": { | ||
| "inherited_from_name": "deco-uc-prod-isolated-aws-us-east-1", | ||
| "inherited_from_type": "METASTORE", | ||
| "value": "ENABLE" | ||
| }, | ||
| "enable_predictive_optimization": "INHERIT", | ||
| "full_name": "main.schema_out_of_band_principal_[UNIQUE_NAME]", | ||
| "metastore_id": "[UUID]", | ||
| "name": "schema_out_of_band_principal_[UNIQUE_NAME]", | ||
| "owner": "[USERNAME]", | ||
| "schema_id": "[UUID]", | ||
| "updated_at": [UNIX_TIME_MILLIS][1], | ||
| "updated_by": "[USERNAME]" | ||
| } | ||
| }, | ||
| "resources.schemas.grants_schema.grants": { | ||
| "depends_on": [ | ||
| { | ||
| "node": "resources.schemas.grants_schema", | ||
| "label": "${resources.schemas.grants_schema.id}" | ||
| } | ||
| ], | ||
| "action": "skip", | ||
| "remote_state": { | ||
| "securable_type": "schema", | ||
| "full_name": "main.schema_out_of_band_principal_[UNIQUE_NAME]", | ||
| "__embed__": [ | ||
| { | ||
| "principal": "[USERNAME]", | ||
| "privileges": [ | ||
| "CREATE_TABLE" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
acceptance/bundle/resources/grants/schemas/out_of_band_principal/out.plan2.terraform.json
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,11 @@ | ||
| { | ||
| "cli_version": "[DEV_VERSION]", | ||
| "plan": { | ||
| "resources.schemas.grants_schema": { | ||
| "action": "skip" | ||
| }, | ||
| "resources.schemas.grants_schema.grants": { | ||
| "action": "skip" | ||
| } | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
acceptance/bundle/resources/grants/schemas/out_of_band_principal/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
acceptance/bundle/resources/grants/schemas/out_of_band_principal/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,30 @@ | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/schema-grants-out-of-band-principal-[UNIQUE_NAME]/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] grants update schema main.schema_out_of_band_principal_[UNIQUE_NAME] --json @update.json | ||
|
|
||
| >>> [CLI] bundle plan -o json | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/schema-grants-out-of-band-principal-[UNIQUE_NAME]/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] bundle plan -o json | ||
|
|
||
| >>> errcode [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.schemas.grants_schema | ||
|
|
||
| This action will result in the deletion of the following UC schemas. Any underlying data may be lost: | ||
| delete resources.schemas.grants_schema | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/schema-grants-out-of-band-principal-[UNIQUE_NAME]/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
17 changes: 17 additions & 0 deletions
17
acceptance/bundle/resources/grants/schemas/out_of_band_principal/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,17 @@ | ||
| SCHEMA_NAME=schema_out_of_band_principal_$UNIQUE_NAME | ||
| SCHEMA_FULL_NAME=main.$SCHEMA_NAME | ||
|
|
||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| trace errcode $CLI bundle destroy --auto-approve | ||
| rm -f out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| trace $CLI bundle deploy | ||
| trace $CLI grants update schema "$SCHEMA_FULL_NAME" --json @update.json > /dev/null | ||
| $CLI grants get schema "$SCHEMA_FULL_NAME" | gron.py --noindex | sort | contains.py "$CURRENT_USER_NAME" 'deco-test-user@databricks.com' > /dev/null | ||
| trace $CLI bundle plan -o json > out.plan.$DATABRICKS_BUNDLE_ENGINE.json | ||
| trace $CLI bundle deploy | ||
| trace $CLI bundle plan -o json > out.plan2.$DATABRICKS_BUNDLE_ENGINE.json |
8 changes: 8 additions & 0 deletions
8
acceptance/bundle/resources/grants/schemas/out_of_band_principal/update.json
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,8 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "principal": "deco-test-user@databricks.com", | ||
| "add": ["USE_SCHEMA"] | ||
| } | ||
| ] | ||
| } |
13 changes: 13 additions & 0 deletions
13
acceptance/bundle/resources/grants/schemas/remove_principal/databricks.yml.tmpl
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,13 @@ | ||
| bundle: | ||
| name: schema-grants-remove-principal-$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| schemas: | ||
| grants_schema: | ||
| name: schema_remove_principal_$UNIQUE_NAME | ||
| catalog_name: main | ||
| grants: | ||
| - principal: $CURRENT_USER_NAME | ||
| privileges: | ||
| - CREATE_TABLE | ||
| - { principal: deco-test-user@databricks.com, privileges: [USE_SCHEMA] } # TO_REMOVE |
2 changes: 2 additions & 0 deletions
2
acceptance/bundle/resources/grants/schemas/remove_principal/out.grants.direct.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,2 @@ | ||
| json.privilege_assignments[].principal = "[USERNAME]"; | ||
| json.privilege_assignments[].privileges[] = "CREATE_TABLE"; |
2 changes: 2 additions & 0 deletions
2
acceptance/bundle/resources/grants/schemas/remove_principal/out.grants.terraform.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,2 @@ | ||
| json.privilege_assignments[].principal = "[USERNAME]"; | ||
| json.privilege_assignments[].privileges[] = "CREATE_TABLE"; |
6 changes: 6 additions & 0 deletions
6
acceptance/bundle/resources/grants/schemas/remove_principal/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.