Process PR feedback

This commit is contained in:
Lennart Kats 2024-09-22 16:07:35 +02:00
parent bfe36fc397
commit bde209c3bf
No known key found for this signature in database
GPG Key ID: 1EB8B57673197023
3 changed files with 8 additions and 16 deletions

View File

@ -59,7 +59,7 @@ func analyzeBundlePermissions(b *bundle.Bundle) (bool, string) {
currentUser := b.Config.Workspace.CurrentUser.UserName
targetPermissions := b.Config.Permissions
for _, p := range targetPermissions {
if p.Level != CAN_MANAGE && p.Level != IS_OWNER {
if p.Level != CAN_MANAGE {
continue
}

View File

@ -32,22 +32,14 @@ func TestPermissionDiagnosticsApplyFail(t *testing.T) {
require.Contains(t, diags[0].Summary, "permissions section should include testuser@databricks.com or one of their groups with CAN_MANAGE permissions")
}
func TestPermissionDiagnosticsApplySuccessWithOwner(t *testing.T) {
b := mockBundle([]resources.Permission{
{Level: "IS_OWNER", UserName: "testuser@databricks.com"},
})
diags := permissions.PermissionDiagnostics().Apply(context.Background(), b)
require.Empty(t, diags)
}
func mockBundle(permissions []resources.Permission) *bundle.Bundle {
return &bundle.Bundle{
Config: config.Root{
Workspace: config.Workspace{
CurrentUser: &config.User{
User: &iam.User{
UserName: "testuser@databricks.com",
UserName: "testuser@databricks.com",
DisplayName: "Test User",
Groups: []iam.ComplexValue{
{Display: "testgroup"},
},

View File

@ -15,7 +15,7 @@ func TestPermissionsReportPermissionDeniedWithGroup(t *testing.T) {
})
diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath")
expected := "EPERM3: unable to deploy to testpath as testuser@databricks.com. Cannot apply local deployment permissions.\n" +
expected := "EPERM3: unable to deploy to testpath as Test User. Cannot apply local deployment permissions.\n" +
"For assistance, contact the owners of this project.\n" +
"They can redeploy the project to apply the latest set of permissions.\n" +
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions."
@ -28,7 +28,7 @@ func TestPermissionsReportPermissionDeniedWithOtherGroup(t *testing.T) {
})
diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath")
expected := "EPERM1: unable to deploy to testpath as testuser@databricks.com.\n" +
expected := "EPERM1: unable to deploy to testpath as Test User.\n" +
"Please make sure the current user or one of their groups is listed under the permissions of this bundle.\n" +
"For assistance, users or groups with appropriate permissions may include: othergroup.\n" +
"They may need to redeploy the bundle to apply the new permissions.\n" +
@ -42,7 +42,7 @@ func TestPermissionsReportPermissionDeniedWithoutPermission(t *testing.T) {
})
diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath")
expected := "EPERM1: unable to deploy to testpath as testuser@databricks.com.\n" +
expected := "EPERM1: unable to deploy to testpath as Test User.\n" +
"Please make sure the current user or one of their groups is listed under the permissions of this bundle.\n" +
"For assistance, contact the owners of this project.\n" +
"They may need to redeploy the bundle to apply the new permissions.\n" +
@ -54,7 +54,7 @@ func TestPermissionsReportPermissionDeniedNilPermission(t *testing.T) {
b := mockBundle(nil)
diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath")
expected := "EPERM1: unable to deploy to testpath as testuser@databricks.com.\n" +
expected := "EPERM1: unable to deploy to testpath as Test User.\n" +
"Please make sure the current user or one of their groups is listed under the permissions of this bundle.\n" +
"For assistance, contact the owners of this project.\n" +
"They may need to redeploy the bundle to apply the new permissions.\n" +
@ -69,7 +69,7 @@ func TestPermissionsReportFindOtherOwners(t *testing.T) {
})
diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath")
require.ErrorContains(t, diags.Error(), "EPERM3: unable to deploy to testpath as testuser@databricks.com. Cannot apply local deployment permissions.\n"+
require.ErrorContains(t, diags.Error(), "EPERM3: unable to deploy to testpath as Test User. Cannot apply local deployment permissions.\n"+
"For assistance, users or groups with appropriate permissions may include: alice@databricks.com.\n"+
"They can redeploy the project to apply the latest set of permissions.\n"+
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions.")