-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy pathscript
More file actions
executable file
·45 lines (36 loc) · 1.84 KB
/
Copy pathscript
File metadata and controls
executable file
·45 lines (36 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
export EMBED_CREDENTIALS="false"
cleanup() {
trace $CLI bundle destroy --auto-approve
rm out.requests.txt
}
trap cleanup EXIT
# Helper functions for dashboard change-* tests
# Deploy the dashboard and capture the ID
deploy_dashboard() {
envsubst < databricks.yml.tmpl > databricks.yml
trace $CLI bundle plan
trace $CLI bundle deploy
dashboard_id=$($CLI bundle summary --output json | jq -r '.resources.dashboards.my_dashboard.id')
trace $CLI lakeview get $dashboard_id | jq "{display_name, lifecycle_state, parent_path, path, serialized_dashboard, warehouse_id}"
trace $CLI lakeview get-published $dashboard_id | jq "{warehouse_id, embed_credentials}"
}
# Create the dashboard with embed_credentials=false
deploy_dashboard
# Capture the dashboard ID as a replacement.
dashboard_id=$($CLI bundle summary --output json | jq -r '.resources.dashboards.my_dashboard.id')
echo "$dashboard_id:DASHBOARD_ID" >> ACC_REPLS
add_repl.py "$($CLI lakeview get $dashboard_id | jq -r '.etag')" ETAG
# Change embed_credentials to true - this should trigger an update
export EMBED_CREDENTIALS="true"
deploy_dashboard
# Print API requests made to create parent_path or create / update the dashboard.
# Terraform serialized OUTPUT_ONLY fields in the request body while direct does not.
# That's why we write the requests to separate files.
cat out.requests.txt | \
jq 'select(.method == "PATCH")' | \
jq 'select( (.path | contains("/api/2.0/lakeview/dashboards")) or ((.path == "/api/2.0/workspace/mkdirs") and (.body.path | contains("/default/resources"))))' \
> out.patch.requests.$DATABRICKS_BUNDLE_ENGINE.txt
cat out.requests.txt | \
jq 'select(.method == "POST")' | \
jq 'select( (.path | contains("/api/2.0/lakeview/dashboards")) or ((.path == "/api/2.0/workspace/mkdirs") and (.body.path | contains("/default/resources"))))' \
> out.post.requests.txt