Skip to content

Commit

Permalink
feat: Rename "in-place" to "source-linked"
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyakuz-db committed Nov 18, 2024
1 parent e8825d5 commit 1d7b27e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions bundle/config/mutator/apply_presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
dashboard.DisplayName = prefix + dashboard.DisplayName
}

if config.IsExplicitlyEnabled((b.Config.Presets.InPlaceDeployment)) {
if config.IsExplicitlyEnabled((b.Config.Presets.SourceLinkedDeployment)) {
root := b.SyncRootPath
isInWorkspace := strings.HasPrefix(root, "/Workspace/")
if isInWorkspace && dbr.RunsOnRuntime(ctx) {
b.Config.Workspace.FilePath = root
} else {
disabled := false
b.Config.Presets.InPlaceDeployment = &disabled
diags = diags.Extend(diag.Warningf("in-place deployment is available only in the Databricks Workspace"))
b.Config.Presets.SourceLinkedDeployment = &disabled
diags = diags.Extend(diag.Warningf("source-linked deployment is available only in the Databricks Workspace"))
}
}

Expand Down
12 changes: 6 additions & 6 deletions bundle/config/mutator/apply_presets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ func TestApplyPresetsResourceNotDefined(t *testing.T) {
}
}

func TestApplyPresetsInPlaceDeployment(t *testing.T) {
func TestApplyPresetsSourceLinkedDeployment(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("this test is not applicable on Windows because in-place works only in the Databricks Workspace")
t.Skip("this test is not applicable on Windows because source-linked mode works only in the Databricks Workspace")
}

testContext := context.Background()
Expand Down Expand Up @@ -405,7 +405,7 @@ func TestApplyPresetsInPlaceDeployment(t *testing.T) {
initialValue: &enabled,
expectedValue: &disabled,
expectedFilePath: remotePath,
expectedWarning: "in-place deployment is available only in the Databricks Workspace",
expectedWarning: "source-linked deployment is available only in the Databricks Workspace",
},
{
name: "preset enabled, bundle in Workspace, not databricks runtime",
Expand All @@ -414,7 +414,7 @@ func TestApplyPresetsInPlaceDeployment(t *testing.T) {
initialValue: &enabled,
expectedValue: &disabled,
expectedFilePath: remotePath,
expectedWarning: "in-place deployment is available only in the Databricks Workspace",
expectedWarning: "source-linked deployment is available only in the Databricks Workspace",
},
{
name: "preset disabled, bundle in Workspace, databricks runtime",
Expand All @@ -441,7 +441,7 @@ func TestApplyPresetsInPlaceDeployment(t *testing.T) {
SyncRootPath: tt.bundlePath,
Config: config.Root{
Presets: config.Presets{
InPlaceDeployment: tt.initialValue,
SourceLinkedDeployment: tt.initialValue,
},
Workspace: config.Workspace{
FilePath: remotePath,
Expand All @@ -459,7 +459,7 @@ func TestApplyPresetsInPlaceDeployment(t *testing.T) {
}

require.Equal(t, tt.expectedFilePath, b.Config.Workspace.FilePath)
require.Equal(t, tt.expectedValue, b.Config.Presets.InPlaceDeployment)
require.Equal(t, tt.expectedValue, b.Config.Presets.SourceLinkedDeployment)
})
}

Expand Down
4 changes: 2 additions & 2 deletions bundle/config/mutator/process_target_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ func transformDevelopmentMode(ctx context.Context, b *bundle.Bundle) {
t.TriggerPauseStatus = config.Paused
}

if !config.IsExplicitlyDisabled(t.InPlaceDeployment) {
if !config.IsExplicitlyDisabled(t.SourceLinkedDeployment) {
root := b.SyncRootPath
isInWorkspace := strings.HasPrefix(root, "/Workspace/")
if isInWorkspace && dbr.RunsOnRuntime(ctx) {
enabled := true
t.InPlaceDeployment = &enabled
t.SourceLinkedDeployment = &enabled
}
}

Expand Down
18 changes: 9 additions & 9 deletions bundle/config/mutator/process_target_mode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,31 +520,31 @@ func TestPipelinesDevelopmentDisabled(t *testing.T) {
assert.False(t, b.Config.Resources.Pipelines["pipeline1"].PipelineSpec.Development)
}

func TestInPlaceDeploymentEnabled(t *testing.T) {
b, diags := processInPlaceBundle(t, true)
func TestSourceLinkedDeploymentEnabled(t *testing.T) {
b, diags := processSourceLinkedBundle(t, true)
require.NoError(t, diags.Error())
assert.True(t, *b.Config.Presets.InPlaceDeployment)
assert.True(t, *b.Config.Presets.SourceLinkedDeployment)
assert.Equal(t, b.Config.Workspace.FilePath, b.SyncRootPath)
}

func TestInPlaceDeploymentDisabled(t *testing.T) {
b, diags := processInPlaceBundle(t, false)
func TestSourceLinkedDeploymentDisabled(t *testing.T) {
b, diags := processSourceLinkedBundle(t, false)
require.NoError(t, diags.Error())
assert.False(t, *b.Config.Presets.InPlaceDeployment)
assert.False(t, *b.Config.Presets.SourceLinkedDeployment)
assert.NotEqual(t, b.Config.Workspace.FilePath, b.SyncRootPath)
}

func processInPlaceBundle(t *testing.T, presetEnabled bool) (*bundle.Bundle, diag.Diagnostics) {
func processSourceLinkedBundle(t *testing.T, presetEnabled bool) (*bundle.Bundle, diag.Diagnostics) {
if runtime.GOOS == "windows" {
t.Skip("this test is not applicable on Windows because in-place works only in the Databricks Workspace")
t.Skip("this test is not applicable on Windows because source-linked mode works only in the Databricks Workspace")
}

b := mockBundle(config.Development)

workspacePath := "/Workspace/[email protected]/"
b.SyncRoot = vfs.MustNew(workspacePath)
b.SyncRootPath = workspacePath
b.Config.Presets.InPlaceDeployment = &presetEnabled
b.Config.Presets.SourceLinkedDeployment = &presetEnabled

ctx := dbr.MockRuntime(context.Background(), true)
m := bundle.Seq(ProcessTargetMode(), ApplyPresets())
Expand Down
4 changes: 2 additions & 2 deletions bundle/config/presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ 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
// SourceLinkedDeployment indicates whether source-linked deployment is enabled. Works only in Databricks 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"`
SourceLinkedDeployment *bool `json:"source_linked_deployment,omitempty"`

// Tags to add to all resources.
Tags map[string]string `json:"tags,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions bundle/deploy/files/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ 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")
if config.IsExplicitlyEnabled(b.Config.Presets.SourceLinkedDeployment) {
cmdio.LogString(ctx, "Source-linked deployment is enabled. Resources will point to the source files directly without making copies")
return nil
}

Expand Down

0 comments on commit 1d7b27e

Please sign in to comment.