Skip to content

Commit aa9d438

Browse files
authored
Show a warning for source-linked deployment without mode development (#3854)
## Changes Show a deprecation warning for source-linked deployments in non-development mode. Further plan is to stop supporting these deployments and raise an error ## Why From @lennartkats-db: > Resource-linked deployments should likely not be supported without mode: development. That’s potentially a trap: they will link to one source first and then to a different source (maybe from a different user) later ## Tests Updated unit test, making proper acceptance test is tricky as we need to run it on DBR
1 parent 0b4f456 commit aa9d438

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

bundle/config/mutator/apply_source_linked_deployment_preset.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ func (m *applySourceLinkedDeploymentPreset) Apply(ctx context.Context, b *bundle
4949
b.Config.Presets.SourceLinkedDeployment = &disabled
5050
return diags
5151
}
52+
53+
if b.Config.Bundle.Mode != config.Development {
54+
path := dyn.NewPath(dyn.Key("targets"), dyn.Key(target), dyn.Key("presets"), dyn.Key("source_linked_deployment"))
55+
diags = diags.Append(
56+
diag.Diagnostic{
57+
Severity: diag.Warning,
58+
Summary: "source-linked deployment in non-development mode is deprecated and will not be supported in a future release",
59+
Paths: []dyn.Path{
60+
path,
61+
},
62+
Locations: b.Config.GetLocations(path[2:].String()),
63+
},
64+
)
65+
}
5266
}
5367

5468
if isDatabricksWorkspace && b.Config.Bundle.Mode == config.Development {

bundle/config/mutator/apply_source_linked_deployment_preset_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func TestApplyPresetsSourceLinkedDeployment(t *testing.T) {
8383
ctx: dbr.MockRuntime(testContext, dbr.Environment{IsDbr: true, Version: "15.4"}),
8484
mutateBundle: func(b *bundle.Bundle) {
8585
b.Config.Workspace.FilePath = "file_path"
86+
b.Config.Bundle.Mode = config.Development
8687
},
8788
initialValue: &enabled,
8889
expectedValue: &enabled,
@@ -95,11 +96,22 @@ func TestApplyPresetsSourceLinkedDeployment(t *testing.T) {
9596
b.Config.Resources.Apps = map[string]*resources.App{
9697
"app": {},
9798
}
99+
b.Config.Bundle.Mode = config.Development
98100
},
99101
initialValue: &enabled,
100102
expectedValue: &enabled,
101103
expectedError: "source-linked deployment is not supported for apps",
102104
},
105+
{
106+
name: "preset enabled, production mode, bundle in Workspace, databricks runtime",
107+
ctx: dbr.MockRuntime(testContext, dbr.Environment{IsDbr: true, Version: "15.4"}),
108+
mutateBundle: func(b *bundle.Bundle) {
109+
b.Config.Bundle.Mode = config.Production
110+
},
111+
initialValue: &enabled,
112+
expectedValue: &enabled,
113+
expectedWarning: "source-linked deployment in non-development mode is deprecated and will not be supported in a future release",
114+
},
103115
}
104116

105117
for _, tt := range tests {

0 commit comments

Comments
 (0)