Skip to content

Commit 2c0a2f0

Browse files
bundle: Add genie_space resource (direct engine only) (#5282)
## Summary Introduces a new `genie_space` bundle resource (direct-engine only) that mirrors the existing `dashboard` pattern. Resolves #3008 Closes #4191 ## Test plan - [x] CI - [x] Cloud tests pass - [x] Manual live workspace verification This pull request and its description were written by Isaac.
1 parent 9eb7725 commit 2c0a2f0

166 files changed

Lines changed: 3945 additions & 12 deletions

File tree

Some content is hidden

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

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Set the default `data_security_mode` to `DATA_SECURITY_MODE_AUTO` in bundle templates ([#5452](https://github.com/databricks/cli/pull/5452)).
1919
* Mark vector search index index_subtype as backend_default to prevent drift after deployment ([#5454](https://github.com/databricks/cli/pull/5454)).
2020
* `bundle deployment migrate`: handle resources added to or removed from `databricks.yml` since the last Terraform deploy ([#5463](https://github.com/databricks/cli/pull/5463)).
21+
* Add the `genie_spaces` bundle resource for managing Databricks Genie spaces as code, plus `bundle generate genie-space` to import an existing space. Direct deployment engine only ([#5282](https://github.com/databricks/cli/pull/5282)).
2122

2223
### Dependency updates
2324

acceptance/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# uploading the file's content to a workspace.
55
*.txt text eol=lf
66
*.lvdash.json text eol=lf
7+
*.geniespace.json text eol=lf
78

89
# The out.test.toml file is autogenerated based on the merged test.toml view.
910
out.test.toml linguist-generated=true
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
bundle:
2+
name: test-bundle-$UNIQUE_NAME
3+
4+
resources:
5+
genie_spaces:
6+
genie_space1:
7+
title: $GENIE_SPACE_TITLE
8+
warehouse_id: "test-warehouse-id"
9+
parent_path: /Users/$CURRENT_USER_NAME
10+
# Inline body matches the out-of-band-created space byte-for-byte, so the
11+
# only possible post-bind drift signal is the etag.
12+
serialized_space:
13+
version: 1

acceptance/bundle/deployment/bind/genie_space/out.test.toml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
>>> [CLI] bundle deployment bind genie_space1 [GENIE_SPACE_ID] --auto-approve
3+
Updating deployment state...
4+
Successfully bound genie_space with an id '[GENIE_SPACE_ID]'
5+
Run 'bundle deploy' to deploy changes to your workspace
6+
7+
>>> [CLI] bundle plan
8+
Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged
9+
10+
>>> [CLI] bundle deploy
11+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/default/files...
12+
Deploying resources...
13+
Updating deployment state...
14+
Deployment complete!
15+
16+
>>> [CLI] genie get-space [GENIE_SPACE_ID]
17+
{
18+
"parent_path": "/Users/[USERNAME]",
19+
"title": "test genie space [UNIQUE_NAME]",
20+
"warehouse_id": "test-warehouse-id"
21+
}
22+
23+
>>> [CLI] bundle deployment unbind genie_space1
24+
Updating deployment state...
25+
26+
>>> [CLI] bundle destroy --auto-approve
27+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-[UNIQUE_NAME]/default
28+
29+
Deleting files...
30+
Destroy complete!
31+
32+
>>> [CLI] genie get-space [GENIE_SPACE_ID]
33+
{
34+
"parent_path": "/Users/[USERNAME]",
35+
"title": "test genie space [UNIQUE_NAME]",
36+
"warehouse_id": "test-warehouse-id"
37+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
GENIE_SPACE_TITLE="test genie space $UNIQUE_NAME"
2+
3+
export GENIE_SPACE_TITLE
4+
envsubst < databricks.yml.tmpl > databricks.yml
5+
6+
# Create a Genie space out of band, then bind the bundle resource to it.
7+
GENIE_SPACE_ID=$($CLI genie create-space "test-warehouse-id" '{"version":1}' --title "${GENIE_SPACE_TITLE}" | jq -r '.space_id')
8+
9+
cleanupRemoveGenieSpace() {
10+
$CLI genie trash-space "${GENIE_SPACE_ID}"
11+
}
12+
trap cleanupRemoveGenieSpace EXIT
13+
14+
trace $CLI bundle deployment bind genie_space1 "${GENIE_SPACE_ID}" --auto-approve
15+
16+
# Bind must copy the remote etag into state, so the first plan after bind is
17+
# clean. Without that, the etag drift signal (empty stored vs remote) would
18+
# produce a bogus update here.
19+
trace $CLI bundle plan
20+
21+
trace $CLI bundle deploy
22+
23+
trace $CLI genie get-space "${GENIE_SPACE_ID}" | jq --sort-keys '{title, parent_path, warehouse_id}'
24+
25+
trace $CLI bundle deployment unbind genie_space1
26+
27+
trace $CLI bundle destroy --auto-approve
28+
29+
# Read the Genie space again (expecting it still exists and is not deleted):
30+
trace $CLI genie get-space "${GENIE_SPACE_ID}" | jq --sort-keys '{title, parent_path, warehouse_id}'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Local = true
2+
3+
# Genie spaces are only deployed via the direct deployment engine.
4+
EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"]
5+
6+
# Uses a literal warehouse id and a version-sensitive serialized_space, so this
7+
# lifecycle test runs against the local mock server only (overrides the Cloud=true
8+
# inherited from acceptance/bundle/deployment/test.toml).
9+
Cloud = false
10+
11+
[[Repls]]
12+
Old = "[0-9a-f]{32}"
13+
New = "[GENIE_SPACE_ID]"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bundle:
2+
name: genie-space-generate
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"title": "test genie space",
3+
"description": "test description",
4+
"parent_path": "/Workspace/test-$UNIQUE_NAME",
5+
"warehouse_id": "test-warehouse-id",
6+
"serialized_space": "{\"tables\":[],\"questions\":[]}"
7+
}

acceptance/bundle/generate/genie_space/out.test.toml

Lines changed: 3 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)