Show email addresses for regular users

This commit is contained in:
Lennart Kats 2024-09-23 08:40:46 +02:00
parent bde209c3bf
commit a39457ef71
No known key found for this signature in database
GPG Key ID: 1EB8B57673197023
2 changed files with 9 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/libs/auth"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/log"
)
@ -16,9 +17,9 @@ import (
func ReportPossiblePermissionDenied(ctx context.Context, b *bundle.Bundle, path string) diag.Diagnostics {
log.Errorf(ctx, "Failed to update, encountered possible permission error: %v", path)
user := b.Config.Workspace.CurrentUser.DisplayName
if user == "" {
user = b.Config.Workspace.CurrentUser.UserName
user := b.Config.Workspace.CurrentUser.UserName
if auth.IsServicePrincipal(user) {
user = b.Config.Workspace.CurrentUser.DisplayName
}
canManageBundle, assistance := analyzeBundlePermissions(b)

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 Test User. Cannot apply local deployment permissions.\n" +
expected := "EPERM3: unable to deploy to testpath as testuser@databricks.com. 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 Test User.\n" +
expected := "EPERM1: unable to deploy to testpath as testuser@databricks.com.\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 Test User.\n" +
expected := "EPERM1: unable to deploy to testpath as testuser@databricks.com.\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 Test User.\n" +
expected := "EPERM1: unable to deploy to testpath as testuser@databricks.com.\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 Test User. Cannot apply local deployment permissions.\n"+
require.ErrorContains(t, diags.Error(), "EPERM3: unable to deploy to testpath as testuser@databricks.com. 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.")