mirror of https://github.com/databricks/cli.git
fixes
This commit is contained in:
parent
99fbf33ef1
commit
a51c5731fe
|
@ -6,8 +6,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
|
"github.com/databricks/cli/bundle/libraries"
|
||||||
"github.com/databricks/cli/libs/diag"
|
"github.com/databricks/cli/libs/diag"
|
||||||
"github.com/databricks/databricks-sdk-go/service/workspace"
|
"github.com/databricks/databricks-sdk-go/service/workspace"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
type workspaceRootPermissions struct {
|
type workspaceRootPermissions struct {
|
||||||
|
@ -53,46 +55,44 @@ func giveAccessForWorkspaceRoot(ctx context.Context, b *bundle.Bundle) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
w := b.WorkspaceClient().Workspace
|
w := b.WorkspaceClient().Workspace
|
||||||
err := setPermissions(ctx, w, b.Config.Workspace.RootPath, permissions)
|
rootPath := b.Config.Workspace.RootPath
|
||||||
if err != nil {
|
paths := []string{}
|
||||||
return err
|
if !libraries.IsVolumesPath(rootPath) {
|
||||||
|
paths = append(paths, rootPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adding backslash to the root path
|
if !strings.HasSuffix(rootPath, "/") {
|
||||||
rootPath := b.Config.Workspace.RootPath
|
|
||||||
if rootPath[len(rootPath)-1] != '/' {
|
|
||||||
rootPath += "/"
|
rootPath += "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.HasPrefix(b.Config.Workspace.ArtifactPath, rootPath) {
|
if !strings.HasPrefix(b.Config.Workspace.ArtifactPath, rootPath) &&
|
||||||
err = setPermissions(ctx, w, b.Config.Workspace.ArtifactPath, permissions)
|
!libraries.IsVolumesPath(b.Config.Workspace.ArtifactPath) {
|
||||||
if err != nil {
|
paths = append(paths, b.Config.Workspace.ArtifactPath)
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.HasPrefix(b.Config.Workspace.FilePath, rootPath) {
|
if !strings.HasPrefix(b.Config.Workspace.FilePath, rootPath) &&
|
||||||
err = setPermissions(ctx, w, b.Config.Workspace.FilePath, permissions)
|
!libraries.IsVolumesPath(b.Config.Workspace.FilePath) {
|
||||||
if err != nil {
|
paths = append(paths, b.Config.Workspace.FilePath)
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.HasPrefix(b.Config.Workspace.StatePath, rootPath) {
|
if !strings.HasPrefix(b.Config.Workspace.StatePath, rootPath) &&
|
||||||
err = setPermissions(ctx, w, b.Config.Workspace.StatePath, permissions)
|
!libraries.IsVolumesPath(b.Config.Workspace.StatePath) {
|
||||||
if err != nil {
|
paths = append(paths, b.Config.Workspace.StatePath)
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.HasPrefix(b.Config.Workspace.ResourcePath, rootPath) {
|
if !strings.HasPrefix(b.Config.Workspace.ResourcePath, rootPath) &&
|
||||||
err = setPermissions(ctx, w, b.Config.Workspace.ResourcePath, permissions)
|
!libraries.IsVolumesPath(b.Config.Workspace.ResourcePath) {
|
||||||
if err != nil {
|
paths = append(paths, b.Config.Workspace.ResourcePath)
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
g, ctx := errgroup.WithContext(ctx)
|
||||||
|
for _, p := range paths {
|
||||||
|
g.Go(func() error {
|
||||||
|
return setPermissions(ctx, w, p, permissions)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return g.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func setPermissions(ctx context.Context, w workspace.WorkspaceInterface, path string, permissions []workspace.WorkspaceObjectAccessControlRequest) error {
|
func setPermissions(ctx context.Context, w workspace.WorkspaceInterface, path string, permissions []workspace.WorkspaceObjectAccessControlRequest) error {
|
||||||
|
|
Loading…
Reference in New Issue