feat: Rename "in-place" to "source-linked"

This commit is contained in:
Ilya Kuznetsov 2024-11-18 17:21:33 +01:00
parent e8825d559f
commit 1d7b27e0ef
No known key found for this signature in database
GPG Key ID: 91F3DDCF5D21CDDF
6 changed files with 24 additions and 24 deletions

View File

@ -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"))
}
}

View File

@ -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()
@ -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",
@ -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",
@ -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,
@ -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)
})
}

View File

@ -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
}
}

View File

@ -520,23 +520,23 @@ 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)
@ -544,7 +544,7 @@ func processInPlaceBundle(t *testing.T, presetEnabled bool) (*bundle.Bundle, dia
workspacePath := "/Workspace/lennart@company.com/"
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())

View File

@ -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"`

View File

@ -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
}