Skip to content

Commit 269568a

Browse files
authored
Set engine based on state; refactor commands (#3797)
## Changes ### Engine selection Engine is now selected based on available state, rather than env var. The env var is still consulted if there are no local or remote state files. Since we need remote state, this is done during state-pull. This means we don't know engine in bundle validate/summary and in deploy/destroy until we reached that stage. Since we don't know if remote is migrated, we pull both terraform state and direct state all the time and decide based on serial number which to use. ### Command refactoring There are many commands that needed refactoring, so I extracted common bundle steps in cmd/bundle/utils/process.go. This allows to enforce certain order on how things are run and encode assumptions in one place. For example, you cannot pull state until you called phases.Initialize() because certain paths are not initialized. ## Why This makes bundle engine setting sticky, once migrated to direct it'll stay on direct. This will be important for subsequent 'bundle deployment migrate' command.
1 parent a4a1221 commit 269568a

File tree

103 files changed

+1514
-1616
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+1514
-1616
lines changed

acceptance/bundle/python/experimental-compatibility-both-error/output.txt

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,39 @@ Error: failed to apply python mutator: 'experimental/python' and 'python' config
1212
},
1313
"resources": null,
1414
"__locations": {
15-
"files": null,
16-
"locations": null
15+
"files": [
16+
"databricks.yml"
17+
],
18+
"locations": {
19+
"bundle": [
20+
[
21+
0,
22+
2,
23+
3
24+
]
25+
],
26+
"experimental": [
27+
[
28+
0,
29+
9,
30+
3
31+
]
32+
],
33+
"python": [
34+
[
35+
0,
36+
14,
37+
3
38+
]
39+
],
40+
"sync": [
41+
[
42+
0,
43+
4,
44+
7
45+
]
46+
]
47+
}
1748
}
1849
}
1950

acceptance/bundle/resource_deps/bad_ref_string_to_int/out.requests.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
"return_export_info": "true"
1111
}
1212
}
13+
{
14+
"method": "GET",
15+
"path": "/api/2.0/workspace/get-status",
16+
"q": {
17+
"path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/resources.json",
18+
"return_export_info": "true"
19+
}
20+
}
1321
{
1422
"method": "GET",
1523
"path": "/api/2.0/workspace/get-status",

acceptance/bundle/resource_deps/missing_ingestion_definition/out.requests.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@
3535
"return_export_info": "true"
3636
}
3737
}
38+
{
39+
"method": "GET",
40+
"path": "/api/2.0/workspace/get-status",
41+
"q": {
42+
"path": "/Workspace/Users/[USERNAME]/.bundle/test-bundle/default/state/resources.json",
43+
"return_export_info": "true"
44+
}
45+
}
3846
{
3947
"method": "GET",
4048
"path": "/api/2.0/workspace/get-status",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
bundle:
2+
name: test-bundle
3+
4+
resources:
5+
schemas:
6+
foo:
7+
catalog_name: c
8+
name: s
File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
>>> musterr [CLI] bundle plan
3+
Error: parsing [TEST_TMP_DIR]/.databricks/bundle/default/terraform/terraform.tfstate: unexpected end of JSON input
4+
5+
6+
>>> musterr [CLI] bundle plan
7+
Error: parsing [TEST_TMP_DIR]/.databricks/bundle/default/resources.json: unexpected end of JSON input
8+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export DATABRICKS_BUNDLE_ENGINE=""
2+
mkdir -p .databricks/bundle/default/terraform
3+
echo "{" > .databricks/bundle/default/terraform/terraform.tfstate
4+
trace musterr $CLI bundle plan 2>&1 | contains.py 'Error' 'parsing' 'terraform.tfstate' 'unexpected end'
5+
6+
rm .databricks/bundle/default/terraform/terraform.tfstate
7+
echo "{" > .databricks/bundle/default/resources.json
8+
trace musterr $CLI bundle plan 2>&1 | contains.py 'Error' 'parsing' 'resources.json' 'unexpected end'
File renamed without changes.
File renamed without changes.

acceptance/bundle/state/basic/out.test.toml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)