feat: Move FilePath update to apply preset step

This commit is contained in:
Ilya Kuznetsov 2024-11-12 09:58:36 +01:00
parent a43f7ddad0
commit 5a22151580
2 changed files with 10 additions and 11 deletions

View File

@ -222,14 +222,18 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
dashboard.DisplayName = prefix + dashboard.DisplayName dashboard.DisplayName = prefix + dashboard.DisplayName
} }
if config.IsExplicitlyEnabled((b.Config.Presets.InPlaceDeployment)) {
root := b.SyncRoot.Native() root := b.SyncRoot.Native()
_, ok := env.Lookup(ctx, envDatabricksRuntimeVersion) _, ok := env.Lookup(ctx, envDatabricksRuntimeVersion)
isInWorkspace := ok && strings.HasPrefix(root, "/Workspace/") isInWorkspace := ok && strings.HasPrefix(root, "/Workspace/")
if !isInWorkspace { if isInWorkspace {
b.Config.Workspace.FilePath = b.BundleRootPath
} else {
disabled := false disabled := false
b.Config.Presets.InPlaceDeployment = &disabled b.Config.Presets.InPlaceDeployment = &disabled
} }
}
return diags return diags
} }

View File

@ -5,7 +5,6 @@ import (
"path" "path"
"github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config"
"github.com/databricks/cli/libs/diag" "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") 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 == "" { if b.Config.Workspace.FilePath == "" {
b.Config.Workspace.FilePath = path.Join(root, "files") b.Config.Workspace.FilePath = path.Join(root, "files")
} }