Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nextchanges/bundles/permissions-empty-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
An explicit `permissions: []` on a resource is now managed like a non-empty list: the current user is added as the default owner (`IS_OWNER`), matching Terraform. Previously an empty list was treated as if the block were absent.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
bundle:
name: schema-grants-empty-list-$UNIQUE_NAME

resources:
schemas:
grants_schema:
name: schema_grants_empty_list_$UNIQUE_NAME
catalog_name: main
# Unlike permissions, grants have no default owner: an empty list grants
# nothing. Note the engines diverge on create: direct emits a no-op PATCH
# with an empty body, terraform emits no request at all.
grants: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"plan_version": 2,
"cli_version": "[CLI_VERSION]",
"plan": {
"resources.schemas.grants_schema": {
"action": "create",
"new_state": {
"value": {
"catalog_name": "main",
"name": "schema_grants_empty_list_[UNIQUE_NAME]"
}
}
},
"resources.schemas.grants_schema.grants": {
"depends_on": [
{
"node": "resources.schemas.grants_schema",
"label": "${resources.schemas.grants_schema.id}"
}
],
"action": "create",
"new_state": {
"value": {
"securable_type": "schema",
"full_name": ""
},
"vars": {
"full_name": "${resources.schemas.grants_schema.id}"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"cli_version": "[CLI_VERSION]",
"plan": {
"resources.schemas.grants_schema": {
"action": "create"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"method": "PATCH",
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_grants_empty_list_[UNIQUE_NAME]",
"body": {}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions acceptance/bundle/resources/grants/schemas/empty_list/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

>>> [CLI] bundle validate -o json
[]

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/schema-grants-empty-list-[UNIQUE_NAME]/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> 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-empty-list-[UNIQUE_NAME]/default

Deleting files...
Destroy complete!
15 changes: 15 additions & 0 deletions acceptance/bundle/resources/grants/schemas/empty_list/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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 validate -o json | jq .resources.schemas.grants_schema.grants

errcode $CLI bundle plan -o json &> out.plan.$DATABRICKS_BUNDLE_ENGINE.txt
rm -f out.requests.txt

trace $CLI bundle deploy
print_requests.py //permissions > out.requests.deploy.$DATABRICKS_BUNDLE_ENGINE.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Timeout = "5m"
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ resources:
notebook_task:
notebook_path: /Workspace/Users/user@example.com/notebook
source: WORKSPACE
# this is interpreted the same as nil, but it's IMO a bug; it should do default IS_OWNER setting
# An explicit empty list is managed: FixPermissions adds the default IS_OWNER for the current user.
permissions: []
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,29 @@
]
}
}
},
"resources.jobs.foo.permissions": {
"depends_on": [
{
"node": "resources.jobs.foo",
"label": "${resources.jobs.foo.id}"
}
],
"action": "create",
"new_state": {
"value": {
"object_id": "",
"__embed__": [
{
"level": "IS_OWNER",
"user_name": "[USERNAME]"
}
]
},
"vars": {
"object_id": "/jobs/${resources.jobs.foo.id}"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"plan": {
"resources.jobs.foo": {
"action": "create"
},
"resources.jobs.foo.permissions": {
"action": "create"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"method": "PUT",
"path": "/api/2.0/permissions/jobs/[NUMID]",
"body": {
"access_control_list": [
{
"permission_level": "IS_OWNER",
"user_name": "[USERNAME]"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"method": "PUT",
"path": "/api/2.0/permissions/jobs/[NUMID]",
"body": {
"access_control_list": [
{
"permission_level": "IS_OWNER",
"user_name": "[USERNAME]"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"method": "PUT",
"path": "/api/2.0/permissions/jobs/[NUMID]",
"body": {
"access_control_list": [
{
"permission_level": "IS_OWNER",
"user_name": "[USERNAME]"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

>>> [CLI] bundle validate -o json
null
[
{
"level": "IS_OWNER",
"user_name": "[USERNAME]"
}
]

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,18 @@
"label": "${resources.jobs.job_with_permissions.id}"
}
],
"action": "delete",
"action": "update",
"new_state": {
"value": {
"object_id": "/jobs/[JOB_WITH_PERMISSIONS_ID]",
"__embed__": [
{
"level": "IS_OWNER",
"user_name": "[USERNAME]"
}
]
}
},
"remote_state": {
"object_id": "/jobs/[JOB_WITH_PERMISSIONS_ID]",
"__embed__": [
Expand All @@ -95,6 +106,30 @@
"user_name": "[USERNAME]"
}
]
},
"changes": {
"[group_name='data-team']": {
"action": "update",
"old": {
"level": "CAN_MANAGE",
"group_name": "data-team"
},
"remote": {
"level": "CAN_MANAGE",
"group_name": "data-team"
}
},
"[user_name='viewer@example.com']": {
"action": "update",
"old": {
"level": "CAN_VIEW",
"user_name": "viewer@example.com"
},
"remote": {
"level": "CAN_VIEW",
"user_name": "viewer@example.com"
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"action": "skip"
},
"resources.jobs.job_with_permissions.permissions": {
"action": "delete"
"action": "update"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
{
"method": "PUT",
"path": "/api/2.0/permissions/jobs/[JOB_WITH_PERMISSIONS_ID]",
"body": {
"access_control_list": [
{
"permission_level": "IS_OWNER",
"user_name": "[USERNAME]"
}
]
}
}
{
"method": "POST",
"path": "/api/2.2/jobs/delete",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"method": "PUT",
"path": "/api/2.0/permissions/jobs/[JOB_WITH_PERMISSIONS_ID]",
"body": {
"access_control_list": [
{
"permission_level": "IS_OWNER",
"user_name": "[USERNAME]"
}
]
}
}
37 changes: 28 additions & 9 deletions acceptance/bundle/resources/permissions/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,24 @@ DIFF jobs/delete_one/out.requests_destroy.direct.json
"body": {
"job_id": "[JOB_WITH_PERMISSIONS_ID]"
EXACT jobs/empty_list/out.requests.deploy.direct.json
EXACT jobs/empty_list/out.requests.destroy.direct.json
DIFF jobs/empty_list/out.requests.destroy.direct.json
--- jobs/empty_list/out.requests.destroy.direct.json
+++ jobs/empty_list/out.requests.destroy.terraform.json
@@ -1 +1,14 @@
-[]+[
+ {
+ "body": {
+ "access_control_list": [
+ {
+ "permission_level": "IS_OWNER",
+ "user_name": "[USERNAME]"
+ }
+ ]
+ },
+ "method": "PUT",
+ "path": "/api/2.0/permissions/jobs/[NUMID]"
+ }
+]
MATCH jobs/other_can_manage/out.requests.deploy.direct.json
DIFF jobs/other_can_manage/out.requests.destroy.direct.json
--- jobs/other_can_manage/out.requests.destroy.direct.json
Expand Down Expand Up @@ -257,12 +274,11 @@ DIFF jobs/update/out.requests_delete_all.direct.json
+ "path": "/api/2.0/permissions/jobs/[JOB_WITH_PERMISSIONS_ID]"
+ }
+]
EXACT jobs/update/out.requests_destroy.direct.json
DIFF jobs/update/out.requests_set_empty.direct.json
--- jobs/update/out.requests_set_empty.direct.json
+++ jobs/update/out.requests_set_empty.terraform.json
@@ -1 +1,14 @@
-[]+[
DIFF jobs/update/out.requests_destroy.direct.json
--- jobs/update/out.requests_destroy.direct.json
+++ jobs/update/out.requests_destroy.terraform.json
@@ -1,4 +1,16 @@
[
+ {
+ "body": {
+ "access_control_list": [
Expand All @@ -274,8 +290,11 @@ DIFF jobs/update/out.requests_set_empty.direct.json
+ },
+ "method": "PUT",
+ "path": "/api/2.0/permissions/jobs/[JOB_WITH_PERMISSIONS_ID]"
+ }
+]
+ },
{
"body": {
"job_id": "[JOB_WITH_PERMISSIONS_ID]"
EXACT jobs/update/out.requests_set_empty.direct.json
MATCH jobs/viewers/out.requests.deploy.direct.json
DIFF jobs/viewers/out.requests.destroy.direct.json
--- jobs/viewers/out.requests.destroy.direct.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ resources:
pipelines:
foo:
name: foo
# this is interpreted the same as nil, but it's IMO a bug; it should do default IS_OWNER setting
# An explicit empty list is managed: FixPermissions adds the default IS_OWNER for the current user.
permissions: []
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@
"name": "foo"
}
}
},
"resources.pipelines.foo.permissions": {
"depends_on": [
{
"node": "resources.pipelines.foo",
"label": "${resources.pipelines.foo.id}"
}
],
"action": "create",
"new_state": {
"value": {
"object_id": "",
"__embed__": [
{
"level": "IS_OWNER",
"user_name": "[USERNAME]"
}
]
},
"vars": {
"object_id": "/pipelines/${resources.pipelines.foo.id}"
}
}
}
}
}
Loading
Loading