diff --git a/bundle/config/mutator/apply_presets.go b/bundle/config/mutator/apply_presets.go index 59b8547b..2a9b0220 100644 --- a/bundle/config/mutator/apply_presets.go +++ b/bundle/config/mutator/apply_presets.go @@ -9,6 +9,7 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" + "github.com/databricks/cli/libs/dbr" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/dyn" "github.com/databricks/cli/libs/textutil" @@ -221,6 +222,17 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos dashboard.DisplayName = prefix + dashboard.DisplayName } + if config.IsExplicitlyEnabled((b.Config.Presets.InPlaceDeployment)) { + root := b.SyncRoot.Native() + isInWorkspace := strings.HasPrefix(root, "/Workspace/") + if isInWorkspace && dbr.RunsOnRuntime(ctx) { + b.Config.Workspace.FilePath = b.SyncRootPath + } else { + disabled := false + b.Config.Presets.InPlaceDeployment = &disabled + } + } + return diags } diff --git a/bundle/config/mutator/apply_presets_test.go b/bundle/config/mutator/apply_presets_test.go index 24295da4..52efb07b 100644 --- a/bundle/config/mutator/apply_presets_test.go +++ b/bundle/config/mutator/apply_presets_test.go @@ -8,6 +8,7 @@ import ( "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/config/mutator" "github.com/databricks/cli/bundle/config/resources" + "github.com/databricks/cli/libs/vfs" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/databricks/databricks-sdk-go/service/jobs" "github.com/stretchr/testify/require" @@ -55,6 +56,7 @@ func TestApplyPresetsPrefix(t *testing.T) { NamePrefix: tt.prefix, }, }, + SyncRoot: vfs.MustNew(t.TempDir()), } ctx := context.Background() @@ -101,6 +103,7 @@ func TestApplyPresetsPrefixForUcSchema(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { b := &bundle.Bundle{ + SyncRoot: vfs.MustNew(t.TempDir()), Config: config.Root{ Resources: config.Resources{ Schemas: map[string]*resources.Schema{ @@ -180,6 +183,7 @@ func TestApplyPresetsTags(t *testing.T) { Tags: tt.tags, }, }, + SyncRoot: vfs.MustNew(t.TempDir()), } ctx := context.Background() @@ -239,6 +243,7 @@ func TestApplyPresetsJobsMaxConcurrentRuns(t *testing.T) { JobsMaxConcurrentRuns: tt.setting, }, }, + SyncRoot: vfs.MustNew(t.TempDir()), } ctx := context.Background() diag := bundle.Apply(ctx, b, mutator.ApplyPresets()) @@ -264,6 +269,7 @@ func TestApplyPresetsPrefixWithoutJobSettings(t *testing.T) { NamePrefix: "prefix-", }, }, + SyncRoot: vfs.MustNew(t.TempDir()), } ctx := context.Background() @@ -355,6 +361,7 @@ func TestApplyPresetsResourceNotDefined(t *testing.T) { TriggerPauseStatus: config.Paused, }, }, + SyncRoot: vfs.MustNew(t.TempDir()), } ctx := context.Background() diff --git a/bundle/config/mutator/process_target_mode.go b/bundle/config/mutator/process_target_mode.go index 44b53681..6ea0e7ef 100644 --- a/bundle/config/mutator/process_target_mode.go +++ b/bundle/config/mutator/process_target_mode.go @@ -57,6 +57,11 @@ func transformDevelopmentMode(ctx context.Context, b *bundle.Bundle) { t.TriggerPauseStatus = config.Paused } + if !config.IsExplicitlyDisabled(t.InPlaceDeployment) { + enabled := true + t.InPlaceDeployment = &enabled + } + if !config.IsExplicitlyDisabled(t.PipelinesDevelopment) { enabled := true t.PipelinesDevelopment = &enabled diff --git a/bundle/config/mutator/process_target_mode_test.go b/bundle/config/mutator/process_target_mode_test.go index 4135d5fd..04177a32 100644 --- a/bundle/config/mutator/process_target_mode_test.go +++ b/bundle/config/mutator/process_target_mode_test.go @@ -11,6 +11,7 @@ import ( "github.com/databricks/cli/bundle/config/resources" "github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/tags" + "github.com/databricks/cli/libs/vfs" sdkconfig "github.com/databricks/databricks-sdk-go/config" "github.com/databricks/databricks-sdk-go/service/catalog" "github.com/databricks/databricks-sdk-go/service/compute" @@ -140,6 +141,7 @@ func mockBundle(mode config.Mode) *bundle.Bundle { }, }, }, + SyncRoot: vfs.MustNew("/Users/lennart.kats@databricks.com"), // Use AWS implementation for testing. Tagging: tags.ForCloud(&sdkconfig.Config{ Host: "https://company.cloud.databricks.com", diff --git a/bundle/config/presets.go b/bundle/config/presets.go index 61009a25..c5fb6e10 100644 --- a/bundle/config/presets.go +++ b/bundle/config/presets.go @@ -17,6 +17,11 @@ type Presets struct { // JobsMaxConcurrentRuns is the default value for the max concurrent runs of jobs. JobsMaxConcurrentRuns int `json:"jobs_max_concurrent_runs,omitempty"` + // InPlaceDeployment indicates whether in-place deployment is enabled. Works only in workspace + // When set to true, resources created during deployment will point to source files in the workspace instead of their workspace copies. + // No resources will be uploaded to workspace + InPlaceDeployment *bool `json:"in_place_deployment,omitempty"` + // Tags to add to all resources. Tags map[string]string `json:"tags,omitempty"` } diff --git a/bundle/deploy/files/upload.go b/bundle/deploy/files/upload.go index bab4e176..bdad6f01 100644 --- a/bundle/deploy/files/upload.go +++ b/bundle/deploy/files/upload.go @@ -7,6 +7,7 @@ import ( "io/fs" "github.com/databricks/cli/bundle" + "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/permissions" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/diag" @@ -23,6 +24,11 @@ func (m *upload) Name() string { } func (m *upload) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics { + if config.IsExplicitlyEnabled(b.Config.Presets.InPlaceDeployment) { + cmdio.LogString(ctx, "Bundle files uploading skipped: in-place deployment is enabled") + return nil + } + cmdio.LogString(ctx, fmt.Sprintf("Uploading bundle files to %s...", b.Config.Workspace.FilePath)) opts, err := GetSyncOptions(ctx, bundle.ReadOnly(b)) if err != nil {