Skip to content

Commit 995a4c6

Browse files
authored
rm terraform.Interpolate() and terraform.Write() from bundle run (#3169)
## Why These are terraform-specific but not necessary for "bundle run": - terraform.Interpolate: modifies bundle in-place references like resources.jobs.foo.id are replaced with tf-specific references. - terraform.Write: converts in-memory bundle config to terraform format and saves as bundle.tf.json. None of the follow up mutators depend on the above, read bundle.tf.json: - statemgmt.StatePull() downloads state from remote. - statemgmt.Load() merges ids from state file into bundle config and updates modified_status as well/ - bundle/run/* does not depend on terraform as well. Context: https://github.com/databricks/cli/pull/288/files#r2180107197 ## Tests Existing tests: acceptance/bundle/run, acceptance/bundle/integration_whl Additional test to see that state is pulled correctly: acceptance/bundle/run/state-wiped
1 parent 062062d commit 995a4c6

File tree

6 files changed

+56
-12
lines changed

6 files changed

+56
-12
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
bundle:
2+
name: caterpillar
3+
4+
resources:
5+
jobs:
6+
foo:
7+
name: foo
8+
tasks:
9+
- task_key: task
10+
spark_python_task:
11+
python_file: ./foo.py
12+
environment_key: default
13+
14+
environments:
15+
- environment_key: default
16+
spec:
17+
client: "2"

acceptance/bundle/run/state-wiped/foo.py

Whitespace-only changes.
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+
>>> musterr [CLI] bundle run foo
3+
Error: no deployment state. Did you forget to run 'databricks bundle deploy'?
4+
5+
6+
Exit code (musterr): 1
7+
8+
>>> [CLI] bundle deploy
9+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/caterpillar/default/files...
10+
Deploying resources...
11+
Updating deployment state...
12+
Deployment complete!
13+
14+
>>> [CLI] bundle run foo
15+
Run URL: [DATABRICKS_URL]/job/run/[NUMID]
16+
17+
[TIMESTAMP] "run-name" TERMINATED
18+
19+
=== Testing that clean state that affect run command -- it'll fetch the state
20+
>>> rm -fr .databricks
21+
22+
>>> [CLI] bundle run foo
23+
Run URL: [DATABRICKS_URL]/job/run/[NUMID]
24+
25+
[TIMESTAMP] "run-name" TERMINATED
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trace musterr $CLI bundle run foo
2+
trace $CLI bundle deploy
3+
4+
trace $CLI bundle run foo
5+
6+
title "Testing that clean state that affect run command -- it'll fetch the state"
7+
trace rm -fr .databricks
8+
9+
trace $CLI bundle run foo

cmd/bundle/run.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"os"
99

1010
"github.com/databricks/cli/bundle"
11-
"github.com/databricks/cli/bundle/deploy/terraform"
1211
"github.com/databricks/cli/bundle/env"
1312
"github.com/databricks/cli/bundle/phases"
1413
"github.com/databricks/cli/bundle/resources"
@@ -167,17 +166,6 @@ Example usage:
167166
return executeScript(content, cmd, b)
168167
}
169168

170-
// Load resource IDs from terraform state.
171-
if !b.DirectDeployment {
172-
bundle.ApplySeqContext(ctx, b,
173-
terraform.Interpolate(),
174-
terraform.Write(),
175-
)
176-
if logdiag.HasError(ctx) {
177-
return root.ErrAlreadyPrinted
178-
}
179-
}
180-
181169
bundle.ApplySeqContext(ctx, b,
182170
statemgmt.StatePull(),
183171
statemgmt.Load(statemgmt.ErrorOnEmptyState),

0 commit comments

Comments
 (0)