Skip to content

Commit 2798377

Browse files
Add warning when variable interpolation is used in bundle name (#3348)
## Why Users should not be using variable interpolation in the bundle name. Closes backlog item: DECO-827 ## Tests Acceptance test.
1 parent 280e218 commit 2798377

File tree

13 files changed

+106
-6
lines changed

13 files changed

+106
-6
lines changed

acceptance/bundle/debug/direct/out.stderr.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
10:07:59 Info: Phase: initialize pid=12345
2020
10:07:59 Debug: Apply pid=12345 mutator=validate:AllResourcesHaveValues
2121
10:07:59 Debug: Apply pid=12345 mutator=validate:interpolation_in_auth_config
22+
10:07:59 Debug: Apply pid=12345 mutator=validate:no_interpolation_in_bundle_name
2223
10:07:59 Debug: Apply pid=12345 mutator=validate:scripts
2324
10:07:59 Debug: Apply pid=12345 mutator=RewriteSyncPaths
2425
10:07:59 Debug: Apply pid=12345 mutator=SyncDefaultPath

acceptance/bundle/debug/direct/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Validation OK!
1414
+>>> [CLI] bundle validate --debug
1515
10:07:59 Info: start pid=12345 version=[DEV_VERSION] args="[CLI], bundle, validate, --debug"
1616
10:07:59 Debug: Found bundle root at [TEST_TMP_DIR] (file [TEST_TMP_DIR]/databricks.yml) pid=12345
17-
@@ -61,8 +63,4 @@
17+
@@ -62,8 +64,4 @@
1818
10:07:59 Debug: Apply pid=12345 mutator=metadata.AnnotateJobs
1919
10:07:59 Debug: Apply pid=12345 mutator=metadata.AnnotatePipelines
2020
-10:07:59 Debug: Apply pid=12345 mutator=terraform.Initialize

acceptance/bundle/debug/tf/out.stderr.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
10:07:59 Info: Phase: initialize pid=12345
1818
10:07:59 Debug: Apply pid=12345 mutator=validate:AllResourcesHaveValues
1919
10:07:59 Debug: Apply pid=12345 mutator=validate:interpolation_in_auth_config
20+
10:07:59 Debug: Apply pid=12345 mutator=validate:no_interpolation_in_bundle_name
2021
10:07:59 Debug: Apply pid=12345 mutator=validate:scripts
2122
10:07:59 Debug: Apply pid=12345 mutator=RewriteSyncPaths
2223
10:07:59 Debug: Apply pid=12345 mutator=SyncDefaultPath
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
bundle:
2+
name: trees are ${var.color}
3+
4+
variables:
5+
color:
6+
default: "green"
7+
8+
targets:
9+
one:
10+
default: true
11+
12+
two:
13+
bundle:
14+
name: trees are red
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Local = true
2+
Cloud = false
3+
4+
[EnvMatrix]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
>>> [CLI] bundle validate
3+
Warning: Please do not use variable interpolation in the name of your bundle. The name of your bundle
4+
is a part of the path at which your bundle state is stored at by default. Parameterizing it at
5+
runtime can have unexpected consequences like duplicate deployments or resources not being
6+
cleaned up during bundle destroy.
7+
at bundle.name
8+
in databricks.yml:2:9
9+
10+
Name: trees are green
11+
Target: one
12+
Workspace:
13+
User: [USERNAME]
14+
Path: /Workspace/Users/[USERNAME]/.bundle/trees are green/one
15+
16+
Found 1 warning
17+
18+
>>> [CLI] bundle validate --target two
19+
Name: trees are red
20+
Target: two
21+
Workspace:
22+
User: [USERNAME]
23+
Path: /Workspace/Users/[USERNAME]/.bundle/trees are red/two
24+
25+
Validation OK!
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
trace $CLI bundle validate
2+
3+
trace $CLI bundle validate --target two
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Warning: Please do not use variable interpolation in the name of your bundle. The name of your bundle
2+
is a part of the path at which your bundle state is stored at by default. Parameterizing it at
3+
runtime can have unexpected consequences like duplicate deployments or resources not being
4+
cleaned up during bundle destroy.
5+
at bundle.name
6+
in databricks.yml:7:9
7+
18
Error: no value assigned to required variable a. Assignment can be done using "--var", by setting the BUNDLE_VAR_a environment variable, or in .databricks/bundle/<target>/variable-overrides.json file
29

310
Name: empty${var.a}
@@ -6,6 +13,6 @@ Workspace:
613
User: [USERNAME]
714
Path: /Workspace/Users/[USERNAME]/.bundle/empty${var.a}/default
815

9-
Found 1 error
16+
Found 1 error and 1 warning
1017

1118
Exit code: 1

acceptance/bundle/variables/vanilla/databricks.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ variables:
77
description: required variable
88

99
bundle:
10-
name: ${var.a} ${var.b}
10+
name: foobar
11+
12+
resources:
13+
jobs:
14+
one:
15+
name: ${var.a} ${var.b}

acceptance/bundle/variables/vanilla/output.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
>>> errcode [CLI] bundle validate
66
Error: no value assigned to required variable b. Assignment can be done using "--var", by setting the BUNDLE_VAR_b environment variable, or in .databricks/bundle/<target>/variable-overrides.json file
77

8-
Name: ${var.a} ${var.b}
8+
Name: foobar
99
Target: default
1010
Workspace:
1111
User: [USERNAME]
12-
Path: /Workspace/Users/[USERNAME]/.bundle/${var.a} ${var.b}/default
12+
Path: /Workspace/Users/[USERNAME]/.bundle/foobar/default
1313

1414
Found 1 error
1515

0 commit comments

Comments
 (0)