From 77d0e40b5b4887a9586705b401af77f8555e30ed Mon Sep 17 00:00:00 2001 From: Daan Rademaker Date: Mon, 9 Dec 2024 15:23:50 +0100 Subject: [PATCH] fix privilidge typo in volume permissions --- .../permissions/volume_permissions.py | 26 ++++++++++++++----- .../permissions/volumePermissions.ts | 2 +- .../permissions/volumePermissions.test.ts | 8 +++--- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/aws-lambda/src/databricks_cdk/resources/permissions/volume_permissions.py b/aws-lambda/src/databricks_cdk/resources/permissions/volume_permissions.py index 0c18510e..b0ba942c 100644 --- a/aws-lambda/src/databricks_cdk/resources/permissions/volume_permissions.py +++ b/aws-lambda/src/databricks_cdk/resources/permissions/volume_permissions.py @@ -1,7 +1,11 @@ import logging from typing import List -from databricks.sdk.service.catalog import PermissionsList, PrivilegeAssignment, SecurableType +from databricks.sdk.service.catalog import ( + PermissionsList, + PrivilegeAssignment, + SecurableType, +) from pydantic import BaseModel from databricks_cdk.resources.permissions.changes import get_permission_changes @@ -20,16 +24,22 @@ def create_or_update_volume_permissions( properties: VolumePermissionsProperties, ) -> CnfResponse: """Create volume permissions on volume at databricks""" - logger.info(f"Creating volume permissions {properties.privilege_assignments} for volume {properties.volume_name}") + logger.info( + f"Creating volume permissions {properties.privilege_assignments} for volume {properties.volume_name}" + ) workspace_client = get_workspace_client(properties.workspace_url) existing_grants: PermissionsList = workspace_client.grants.get( securable_type=SecurableType.VOLUME, full_name=properties.volume_name ) - permission_changes = get_permission_changes(existing_grants, properties.privilege_assignments) + permission_changes = get_permission_changes( + existing_grants, properties.privilege_assignments + ) workspace_client.grants.update( - securable_type=SecurableType.VOLUME, full_name=properties.volume_name, changes=permission_changes + securable_type=SecurableType.VOLUME, + full_name=properties.volume_name, + changes=permission_changes, ) return CnfResponse( @@ -37,7 +47,9 @@ def create_or_update_volume_permissions( ) -def delete_volume_permissions(properties: VolumePermissionsProperties, physical_resource_id: str) -> CnfResponse: +def delete_volume_permissions( + properties: VolumePermissionsProperties, physical_resource_id: str +) -> CnfResponse: """Deletes all volume permissions on volume at databricks""" workspace_client = get_workspace_client(properties.workspace_url) existing_grants: PermissionsList = workspace_client.grants.get( @@ -47,7 +59,9 @@ def delete_volume_permissions(properties: VolumePermissionsProperties, physical_ permission_changes = get_permission_changes(existing_grants, []) workspace_client.grants.update( - securable_type=SecurableType.VOLUME, full_name=properties.volume_name, changes=permission_changes + securable_type=SecurableType.VOLUME, + full_name=properties.volume_name, + changes=permission_changes, ) return CnfResponse( diff --git a/typescript/src/resources/permissions/volumePermissions.ts b/typescript/src/resources/permissions/volumePermissions.ts index 0dcf4241..b1faddc5 100644 --- a/typescript/src/resources/permissions/volumePermissions.ts +++ b/typescript/src/resources/permissions/volumePermissions.ts @@ -10,7 +10,7 @@ export enum PrivilegeVolume { export interface PrivilegeAssignmentVolume { principal: string - priviliges: Array + privileges: Array } export interface VolumePermissionsProperties { diff --git a/typescript/tests/resources/permissions/volumePermissions.test.ts b/typescript/tests/resources/permissions/volumePermissions.test.ts index d10f6ac4..e3d3aadb 100644 --- a/typescript/tests/resources/permissions/volumePermissions.test.ts +++ b/typescript/tests/resources/permissions/volumePermissions.test.ts @@ -13,7 +13,7 @@ describe("VolumePermissions", () => { privilege_assignments: [ { principal: "some-principal", - priviliges: [ + privileges: [ PrivilegeVolume.APPLY_TAG, PrivilegeVolume.READ_VOLUME, PrivilegeVolume.WRITE_VOLUME, @@ -22,7 +22,7 @@ describe("VolumePermissions", () => { }, { principal: "some-other-principal", - priviliges: [ + privileges: [ PrivilegeVolume.APPLY_TAG, PrivilegeVolume.READ_VOLUME, ] @@ -46,7 +46,7 @@ describe("VolumePermissions", () => { "privilege_assignments": [ { "principal": "some-principal", - "priviliges": [ + "privileges": [ "APPLY_TAG", "READ_VOLUME", "WRITE_VOLUME", @@ -55,7 +55,7 @@ describe("VolumePermissions", () => { }, { "principal": "some-other-principal", - "priviliges": [ + "privileges": [ "APPLY_TAG", "READ_VOLUME" ]