mirror of https://github.com/databricks/cli.git
fixes
This commit is contained in:
parent
ad2790daf6
commit
b91816653a
|
@ -20,9 +20,13 @@ func ApplyWorkspaceRootPermissions() bundle.Mutator {
|
||||||
// Apply implements bundle.Mutator.
|
// Apply implements bundle.Mutator.
|
||||||
func (*workspaceRootPermissions) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
func (*workspaceRootPermissions) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
|
||||||
|
|
||||||
diags := checkWorkspaceRootPermissions(b)
|
if isWorkspaceSharedRoot(b.Config.Workspace.RootPath) {
|
||||||
if len(diags) > 0 {
|
diags := checkWorkspaceRootPermissions(b)
|
||||||
return diags
|
// If there are permissions warnings, return them and do not apply permissions
|
||||||
|
// because they are not set correctly for /Workspace/Shared root anyway
|
||||||
|
if len(diags) > 0 {
|
||||||
|
return diags
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := giveAccessForWorkspaceRoot(ctx, b)
|
err := giveAccessForWorkspaceRoot(ctx, b)
|
||||||
|
@ -85,14 +89,14 @@ func getWorkspaceObjectPermissionLevel(bundlePermission string) (workspace.Works
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isWorkspaceSharedRoot(path string) bool {
|
||||||
|
return strings.HasPrefix(path, "/Workspace/Shared/")
|
||||||
|
}
|
||||||
|
|
||||||
// checkWorkspaceRootPermissions checks that if permissions are set for the workspace root, and workspace root starts with /Workspace/Shared, then permissions should be set for group: users
|
// checkWorkspaceRootPermissions checks that if permissions are set for the workspace root, and workspace root starts with /Workspace/Shared, then permissions should be set for group: users
|
||||||
func checkWorkspaceRootPermissions(b *bundle.Bundle) diag.Diagnostics {
|
func checkWorkspaceRootPermissions(b *bundle.Bundle) diag.Diagnostics {
|
||||||
var diags diag.Diagnostics
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
if !strings.HasPrefix(b.Config.Workspace.RootPath, "/Workspace/Shared/") {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
allUsers := false
|
allUsers := false
|
||||||
for _, p := range b.Config.Permissions {
|
for _, p := range b.Config.Permissions {
|
||||||
if p.GroupName == "users" && p.Level == CAN_MANAGE {
|
if p.GroupName == "users" && p.Level == CAN_MANAGE {
|
||||||
|
|
Loading…
Reference in New Issue