fix: Skip permissions set and check for in-place

This commit is contained in:
Ilya Kuznetsov 2024-11-18 16:05:21 +01:00
parent e65b50cf3c
commit 53e1f6df6a
No known key found for this signature in database
GPG Key ID: 91F3DDCF5D21CDDF
5 changed files with 17 additions and 0 deletions

View File

@ -32,6 +32,10 @@ func (r ReadOnlyBundle) SyncRoot() vfs.Path {
return r.b.SyncRoot
}
func (r ReadOnlyBundle) SyncRootPath() string {
return r.b.SyncRootPath
}
func (r ReadOnlyBundle) WorkspaceClient() *databricks.WorkspaceClient {
return r.b.WorkspaceClient()
}

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"path"
"strings"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/libraries"
@ -30,6 +31,9 @@ func (f *folderPermissions) Apply(ctx context.Context, b bundle.ReadOnlyBundle)
g, ctx := errgroup.WithContext(ctx)
results := make([]diag.Diagnostics, len(bundlePaths))
for i, p := range bundlePaths {
if strings.HasPrefix(p, b.SyncRootPath()) {
continue
}
g.Go(func() error {
results[i] = checkFolderPermission(ctx, b, p)
return nil

View File

@ -77,6 +77,7 @@ func TestFolderPermissionsInheritedWhenRootPathDoesNotExist(t *testing.T) {
func TestValidateFolderPermissionsFailsOnMissingBundlePermission(t *testing.T) {
b := &bundle.Bundle{
SyncRootPath: t.TempDir(),
Config: config.Root{
Workspace: config.Workspace{
RootPath: "/Workspace/Users/foo@bar.com",
@ -129,6 +130,7 @@ func TestValidateFolderPermissionsFailsOnMissingBundlePermission(t *testing.T) {
func TestValidateFolderPermissionsFailsOnPermissionMismatch(t *testing.T) {
b := &bundle.Bundle{
SyncRootPath: t.TempDir(),
Config: config.Root{
Workspace: config.Workspace{
RootPath: "/Workspace/Users/foo@bar.com",
@ -174,6 +176,7 @@ func TestValidateFolderPermissionsFailsOnPermissionMismatch(t *testing.T) {
func TestValidateFolderPermissionsFailsOnNoRootFolder(t *testing.T) {
b := &bundle.Bundle{
SyncRootPath: t.TempDir(),
Config: config.Root{
Workspace: config.Workspace{
RootPath: "/NotExisting",

View File

@ -3,6 +3,7 @@ package permissions
import (
"context"
"fmt"
"strings"
"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/libraries"
@ -59,6 +60,9 @@ func giveAccessForWorkspaceRoot(ctx context.Context, b *bundle.Bundle) error {
g, ctx := errgroup.WithContext(ctx)
for _, p := range bundlePaths {
if strings.HasPrefix(p, b.SyncRootPath) {
continue
}
g.Go(func() error {
return setPermissions(ctx, w, p, permissions)
})

View File

@ -19,6 +19,7 @@ import (
func TestApplyWorkspaceRootPermissions(t *testing.T) {
b := &bundle.Bundle{
SyncRootPath: t.TempDir(),
Config: config.Root{
Workspace: config.Workspace{
RootPath: "/Users/foo@bar.com",
@ -79,6 +80,7 @@ func TestApplyWorkspaceRootPermissions(t *testing.T) {
func TestApplyWorkspaceRootPermissionsForAllPaths(t *testing.T) {
b := &bundle.Bundle{
SyncRootPath: t.TempDir(),
Config: config.Root{
Workspace: config.Workspace{
RootPath: "/Some/Root/Path",