Skip to content

Commit 936b4b5

Browse files
denikIsaac
andauthored
bundle: warn that bundle.terraform is deprecated (#6940)
## Changes `bundle.terraform` (e.g. `exec_path`) has no effect since the Terraform deployment engine was removed. Keep the field so existing configs still load, but warn when it is set (top-level or in a target override): ``` Warning: bundle.terraform is deprecated and has no effect: the Terraform deployment engine has been removed in Databricks CLI v1.20.0 at bundle.terraform in databricks.yml:4:5 ``` ## Tests Unit test and new acceptance test `bundle/validate/terraform-config-deprecated`. This pull request and its description were written by Isaac. --------- Co-authored-by: Isaac <no-reply@databricks.com>
1 parent cda4a87 commit 936b4b5

8 files changed

Lines changed: 81 additions & 7 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Warn that `bundle.terraform` is deprecated and has no effect since the Terraform deployment engine was removed. ([#6940](https://github.com/databricks/cli/pull/6940))
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
bundle:
2+
name: test-bundle
3+
terraform:
4+
exec_path: /usr/local/bin/terraform
5+
6+
targets:
7+
default:
8+
default: true
9+
override:
10+
bundle:
11+
terraform:
12+
exec_path: /opt/terraform
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cloud = false
2+
EnvMatrix.DMS = ["", "true"]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
>>> [CLI] bundle validate
3+
Warning: bundle.terraform is deprecated and has no effect: the Terraform deployment engine has been removed in Databricks CLI v1.20.0
4+
at bundle.terraform
5+
in databricks.yml:4:5
6+
7+
Name: test-bundle
8+
Target: default
9+
Workspace:
10+
User: [USERNAME]
11+
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default
12+
13+
Found 1 warning
14+
15+
>>> [CLI] bundle validate -t override
16+
Warning: bundle.terraform is deprecated and has no effect: the Terraform deployment engine has been removed in Databricks CLI v1.20.0
17+
at bundle.terraform
18+
in databricks.yml:4:5
19+
databricks.yml:12:9
20+
21+
Name: test-bundle
22+
Target: override
23+
Workspace:
24+
User: [USERNAME]
25+
Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle/override
26+
27+
Found 1 warning
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
trace $CLI bundle validate
2+
trace $CLI bundle validate -t override
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Ignore = [".databricks"]

‎bundle/config/validate/validate_engine.go‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import (
1212

1313
type validateEngine struct{ bundle.RO }
1414

15-
// ValidateEngine validates that the bundle.engine setting is valid.
15+
// ValidateEngine validates that the bundle.engine setting is valid and warns
16+
// about the bundle.terraform setting, which has no effect since the Terraform
17+
// deployment engine was removed.
1618
func ValidateEngine() bundle.ReadOnlyMutator {
1719
return &validateEngine{}
1820
}
@@ -22,30 +24,40 @@ func (v *validateEngine) Name() string {
2224
}
2325

2426
func (v *validateEngine) Apply(_ context.Context, b *bundle.Bundle) diag.Diagnostics {
27+
var diags diag.Diagnostics
28+
if tf := dyn.GetValue(b.Config.Value(), "bundle.terraform"); tf.IsValid() {
29+
diags = diags.Append(diag.Diagnostic{
30+
Severity: diag.Warning,
31+
Summary: "bundle.terraform is deprecated and has no effect: " + engine.TerraformRemovedSummary,
32+
Locations: tf.Locations(),
33+
Paths: []dyn.Path{dyn.MustPathFromString("bundle.terraform")},
34+
})
35+
}
36+
2537
configEngine := b.Config.Bundle.Engine
2638
if configEngine == engine.EngineNotSet {
27-
return nil
39+
return diags
2840
}
2941

3042
loc := dyn.GetValue(b.Config.Value(), "bundle.engine").Location()
3143

3244
parsed, ok := engine.Parse(string(configEngine))
3345
if !ok {
34-
return diag.Diagnostics{{
46+
return diags.Append(diag.Diagnostic{
3547
Severity: diag.Error,
3648
Summary: fmt.Sprintf("invalid value %q for bundle.engine (expected %q)", configEngine, engine.EngineDirect),
3749
Locations: []dyn.Location{loc},
38-
}}
50+
})
3951
}
4052

4153
if parsed == engine.EngineTerraform {
42-
return diag.Diagnostics{{
54+
return diags.Append(diag.Diagnostic{
4355
Severity: diag.Error,
4456
Summary: engine.TerraformRemovedSummary,
4557
Detail: engine.TerraformRemovedDetail,
4658
Locations: []dyn.Location{loc},
47-
}}
59+
})
4860
}
4961

50-
return nil
62+
return diags
5163
}

‎bundle/config/validate/validate_engine_test.go‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,20 @@ func TestValidateEngineInvalid(t *testing.T) {
6464
assert.Equal(t, diag.Error, diags[0].Severity)
6565
assert.Contains(t, diags[0].Summary, "invalid")
6666
}
67+
68+
func TestValidateEngineTerraformConfigDeprecated(t *testing.T) {
69+
b := &bundle.Bundle{
70+
Config: config.Root{
71+
Bundle: config.Bundle{
72+
Terraform: &config.Terraform{ExecPath: "/usr/bin/terraform"},
73+
},
74+
},
75+
}
76+
loc := dyn.Location{File: "databricks.yml", Line: 3, Column: 5}
77+
bundletest.SetLocation(b, "bundle.terraform", []dyn.Location{loc})
78+
diags := ValidateEngine().Apply(t.Context(), b)
79+
assert.Len(t, diags, 1)
80+
assert.Equal(t, diag.Warning, diags[0].Severity)
81+
assert.Contains(t, diags[0].Summary, "bundle.terraform is deprecated")
82+
assert.Equal(t, []dyn.Location{loc}, diags[0].Locations)
83+
}

0 commit comments

Comments
 (0)