Skip to content

Commit 1984f7c

Browse files
denikpietern
andauthored
acc: add test for variable in variable (#3375)
This is a surprising feature. Up to version 0.239.0 there was a resolution but due to one round it would leave config in a broken state: ``` ~/work/cli/acceptance/bundle/variables/var_in_var % ./databricks-238 bundle validate -o json -t target_x | jq .variables.final { "default": "${var.foo_x}", "value": "${var.foo_x}" } ``` After 0.239 thanks to multiple rounds of evaluation it is not now resolved fully, but we're not sure if we want to support this. ``` ~/work/cli/acceptance/bundle/variables/var_in_var % ./databricks-239 bundle validate -o json -t target_x | jq .variables.final { "default": "hello from foo x", "value": "hello from foo x" } ``` --------- Co-authored-by: Pieter Noordhuis <[email protected]>
1 parent 513d3de commit 1984f7c

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
bundle:
2+
name: test-bundle
3+
4+
variables:
5+
foo_x:
6+
default: hello from foo x
7+
foo_y:
8+
default: hi from foo y
9+
tail:
10+
default: x
11+
final:
12+
# This works but it's not officially supported, please do not rely on it.
13+
# We might start to reject this config in the future.
14+
default: ${var.foo_${var.tail}}
15+
16+
targets:
17+
target_x:
18+
variables:
19+
tail: x
20+
target_y:
21+
variables:
22+
tail: y
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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
>>> [CLI] bundle validate -o json -t target_x
3+
{
4+
"final": {
5+
"default": "hello from foo x",
6+
"value": "hello from foo x"
7+
},
8+
"foo_x": {
9+
"default": "hello from foo x",
10+
"value": "hello from foo x"
11+
},
12+
"foo_y": {
13+
"default": "hi from foo y",
14+
"value": "hi from foo y"
15+
},
16+
"tail": {
17+
"default": "x",
18+
"value": "x"
19+
}
20+
}
21+
22+
>>> [CLI] bundle validate -o json -t target_y
23+
{
24+
"final": {
25+
"default": "hi from foo y",
26+
"value": "hi from foo y"
27+
},
28+
"foo_x": {
29+
"default": "hello from foo x",
30+
"value": "hello from foo x"
31+
},
32+
"foo_y": {
33+
"default": "hi from foo y",
34+
"value": "hi from foo y"
35+
},
36+
"tail": {
37+
"default": "y",
38+
"value": "y"
39+
}
40+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
trace $CLI bundle validate -o json -t target_x | jq .variables
2+
trace $CLI bundle validate -o json -t target_y | jq .variables

0 commit comments

Comments
 (0)