From 5a22151580540727a9b451014955db3b31d9d23a Mon Sep 17 00:00:00 2001 From: Ilya Kuznetsov Date: Tue, 12 Nov 2024 09:58:36 +0100 Subject: [PATCH] feat: Move FilePath update to apply preset step --- bundle/config/mutator/apply_presets.go | 16 ++++++++++------ bundle/config/mutator/default_workspace_paths.go | 5 ----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/bundle/config/mutator/apply_presets.go b/bundle/config/mutator/apply_presets.go index 4b29f005..cdccf549 100644 --- a/bundle/config/mutator/apply_presets.go +++ b/bundle/config/mutator/apply_presets.go @@ -222,13 +222,17 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos dashboard.DisplayName = prefix + dashboard.DisplayName } - root := b.SyncRoot.Native() - _, ok := env.Lookup(ctx, envDatabricksRuntimeVersion) - isInWorkspace := ok && strings.HasPrefix(root, "/Workspace/") + if config.IsExplicitlyEnabled((b.Config.Presets.InPlaceDeployment)) { + root := b.SyncRoot.Native() + _, ok := env.Lookup(ctx, envDatabricksRuntimeVersion) + isInWorkspace := ok && strings.HasPrefix(root, "/Workspace/") - if !isInWorkspace { - disabled := false - b.Config.Presets.InPlaceDeployment = &disabled + if isInWorkspace { + b.Config.Workspace.FilePath = b.BundleRootPath + } else { + disabled := false + b.Config.Presets.InPlaceDeployment = &disabled + } } return diags diff --git a/bundle/config/mutator/default_workspace_paths.go b/bundle/config/mutator/default_workspace_paths.go index 9dfbf763..02a1ddb3 100644 --- a/bundle/config/mutator/default_workspace_paths.go +++ b/bundle/config/mutator/default_workspace_paths.go @@ -5,7 +5,6 @@ import ( "path" "github.com/databricks/cli/bundle" - "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/libs/diag" ) @@ -26,10 +25,6 @@ func (m *defineDefaultWorkspacePaths) Apply(ctx context.Context, b *bundle.Bundl return diag.Errorf("unable to define default workspace paths: workspace root not defined") } - if config.IsExplicitlyEnabled((b.Config.Presets.InPlaceDeployment)) { - b.Config.Workspace.FilePath = b.BundleRootPath - } - if b.Config.Workspace.FilePath == "" { b.Config.Workspace.FilePath = path.Join(root, "files") }