mirror of https://github.com/databricks/cli.git
feat: Add Databricks Workspace conditions to dev mode setting. Add warning if conditions not met when preset is enabled by user
This commit is contained in:
parent
80ea3a05e3
commit
e7165ec17a
|
@ -230,6 +230,7 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
|
|||
} else {
|
||||
disabled := false
|
||||
b.Config.Presets.InPlaceDeployment = &disabled
|
||||
diags = diags.Extend(diag.Warningf("in-place deployment is available only in the Databricks Workspace"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -387,6 +387,7 @@ func TestApplyPresetsInPlaceDeployment(t *testing.T) {
|
|||
initialValue *bool
|
||||
expectedValue *bool
|
||||
expectedFilePath string
|
||||
expectedWarning string
|
||||
}{
|
||||
{
|
||||
name: "preset enabled, bundle in Workspace, databricks runtime",
|
||||
|
@ -395,6 +396,7 @@ func TestApplyPresetsInPlaceDeployment(t *testing.T) {
|
|||
initialValue: &enabled,
|
||||
expectedValue: &enabled,
|
||||
expectedFilePath: workspacePath,
|
||||
expectedWarning: "",
|
||||
},
|
||||
{
|
||||
name: "preset enabled, bundle not in Workspace, databricks runtime",
|
||||
|
@ -403,6 +405,7 @@ func TestApplyPresetsInPlaceDeployment(t *testing.T) {
|
|||
initialValue: &enabled,
|
||||
expectedValue: &disabled,
|
||||
expectedFilePath: remotePath,
|
||||
expectedWarning: "in-place deployment is available only in the Databricks Workspace",
|
||||
},
|
||||
{
|
||||
name: "preset enabled, bundle in Workspace, not databricks runtime",
|
||||
|
@ -411,6 +414,7 @@ func TestApplyPresetsInPlaceDeployment(t *testing.T) {
|
|||
initialValue: &enabled,
|
||||
expectedValue: &disabled,
|
||||
expectedFilePath: remotePath,
|
||||
expectedWarning: "in-place deployment is available only in the Databricks Workspace",
|
||||
},
|
||||
{
|
||||
name: "preset disabled, bundle in Workspace, databricks runtime",
|
||||
|
@ -450,8 +454,13 @@ func TestApplyPresetsInPlaceDeployment(t *testing.T) {
|
|||
t.Fatalf("unexpected error: %v", diags)
|
||||
}
|
||||
|
||||
if tt.expectedWarning != "" {
|
||||
require.Equal(t, tt.expectedWarning, diags[0].Summary)
|
||||
}
|
||||
|
||||
require.Equal(t, tt.expectedFilePath, b.Config.Workspace.FilePath)
|
||||
require.Equal(t, tt.expectedValue, b.Config.Presets.InPlaceDeployment)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,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/iamutil"
|
||||
|
@ -63,8 +64,13 @@ func transformDevelopmentMode(ctx context.Context, b *bundle.Bundle) {
|
|||
}
|
||||
|
||||
if !config.IsExplicitlyDisabled(t.PipelinesDevelopment) {
|
||||
enabled := true
|
||||
t.PipelinesDevelopment = &enabled
|
||||
root := b.SyncRootPath
|
||||
isInWorkspace := strings.HasPrefix(root, "/Workspace/")
|
||||
|
||||
if isInWorkspace && dbr.RunsOnRuntime(ctx) {
|
||||
enabled := true
|
||||
t.PipelinesDevelopment = &enabled
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue