mirror of https://github.com/databricks/cli.git
Process PR feedback
This commit is contained in:
parent
bfe36fc397
commit
bde209c3bf
|
@ -59,7 +59,7 @@ func analyzeBundlePermissions(b *bundle.Bundle) (bool, string) {
|
||||||
currentUser := b.Config.Workspace.CurrentUser.UserName
|
currentUser := b.Config.Workspace.CurrentUser.UserName
|
||||||
targetPermissions := b.Config.Permissions
|
targetPermissions := b.Config.Permissions
|
||||||
for _, p := range targetPermissions {
|
for _, p := range targetPermissions {
|
||||||
if p.Level != CAN_MANAGE && p.Level != IS_OWNER {
|
if p.Level != CAN_MANAGE {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,15 +32,6 @@ 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")
|
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 {
|
func mockBundle(permissions []resources.Permission) *bundle.Bundle {
|
||||||
return &bundle.Bundle{
|
return &bundle.Bundle{
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
|
@ -48,6 +39,7 @@ func mockBundle(permissions []resources.Permission) *bundle.Bundle {
|
||||||
CurrentUser: &config.User{
|
CurrentUser: &config.User{
|
||||||
User: &iam.User{
|
User: &iam.User{
|
||||||
UserName: "testuser@databricks.com",
|
UserName: "testuser@databricks.com",
|
||||||
|
DisplayName: "Test User",
|
||||||
Groups: []iam.ComplexValue{
|
Groups: []iam.ComplexValue{
|
||||||
{Display: "testgroup"},
|
{Display: "testgroup"},
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,7 +15,7 @@ func TestPermissionsReportPermissionDeniedWithGroup(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath")
|
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" +
|
"For assistance, contact the owners of this project.\n" +
|
||||||
"They can redeploy the project to apply the latest set of permissions.\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."
|
"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")
|
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" +
|
"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" +
|
"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" +
|
"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")
|
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" +
|
"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" +
|
"For assistance, contact the owners of this project.\n" +
|
||||||
"They may need to redeploy the bundle to apply the new permissions.\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)
|
b := mockBundle(nil)
|
||||||
|
|
||||||
diags := permissions.ReportPossiblePermissionDenied(context.Background(), b, "testpath")
|
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" +
|
"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" +
|
"For assistance, contact the owners of this project.\n" +
|
||||||
"They may need to redeploy the bundle to apply the new permissions.\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")
|
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"+
|
"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"+
|
"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.")
|
"Please refer to https://docs.databricks.com/dev-tools/bundles/permissions.html for more on managing permissions.")
|
||||||
|
|
Loading…
Reference in New Issue