Skip to content

Commit 4ddfb5e

Browse files
committed
acceptance: use templates for bundle_default_profile scenarios
Replace inline heredocs and per-scenario subdirectories (./bundle-with-host, ./bundle-with-profile) with three committed template files: databricks.yml.{no-host,with-host,with-profile}.tmpl. The script copies (or envsubsts, for the host-pinned template) the active template into databricks.yml before each phase, so the active bundle is always at the test root. Follows pietern's suggestion in #5214. Co-authored-by: Isaac
1 parent 3f1e9c3 commit 4ddfb5e

5 files changed

Lines changed: 17 additions & 22 deletions

File tree

acceptance/auth/bundle_default_profile/databricks.yml renamed to acceptance/auth/bundle_default_profile/databricks.yml.no-host.tmpl

File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bundle:
2+
name: bundle-with-host
3+
4+
workspace:
5+
host: $DATABRICKS_HOST
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bundle:
2+
name: bundle-with-profile
3+
4+
workspace:
5+
profile: other

acceptance/auth/bundle_default_profile/script

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,25 @@ unset DATABRICKS_HOST
2020
unset DATABRICKS_TOKEN
2121
unset DATABRICKS_CONFIG_PROFILE
2222

23+
cp databricks.yml.no-host.tmpl databricks.yml
2324
title "Bundle without workspace.host: default_profile is honored\n"
2425
trace $CLI bundle validate -o json | jq '{host: .workspace.host, profile: .workspace.profile}'
2526

27+
cp databricks.yml.no-host.tmpl databricks.yml
2628
title "--profile overrides default_profile (negative case)\n"
2729
trace errcode $CLI bundle validate -p other -o json | jq '{host: .workspace.host, profile: .workspace.profile}'
2830

2931
# Switch to a bundle that pins workspace.host. The default_profile guard in
3032
# configureProfile must NOT apply default_profile here, because that would
3133
# silently route the user to a profile pointing at a different host than the
3234
# bundle declares.
33-
mkdir -p ./bundle-with-host
34-
cat > ./bundle-with-host/databricks.yml <<EOF
35-
bundle:
36-
name: bundle-with-host
37-
38-
workspace:
39-
host: $host_value
40-
EOF
41-
35+
DATABRICKS_HOST="$host_value" envsubst < databricks.yml.with-host.tmpl > databricks.yml
4236
title "Bundle with workspace.host: default_profile is NOT applied\n"
43-
(cd ./bundle-with-host && trace errcode $CLI bundle validate -o json | jq '{host: .workspace.host, profile: .workspace.profile}')
37+
trace errcode $CLI bundle validate -o json | jq '{host: .workspace.host, profile: .workspace.profile}'
4438

4539
# Switch to a bundle that pins workspace.profile but no host. The pinned
4640
# profile must win over default_profile — configureProfile's guard skips
4741
# default_profile when workspace.profile is already set.
48-
mkdir -p ./bundle-with-profile
49-
cat > ./bundle-with-profile/databricks.yml <<EOF
50-
bundle:
51-
name: bundle-with-profile
52-
53-
workspace:
54-
profile: other
55-
EOF
56-
42+
cp databricks.yml.with-profile.tmpl databricks.yml
5743
title "Bundle with workspace.profile: pinned profile wins over default_profile\n"
58-
(cd ./bundle-with-profile && trace errcode $CLI bundle validate -o json | jq '{host: .workspace.host, profile: .workspace.profile}')
44+
trace errcode $CLI bundle validate -o json | jq '{host: .workspace.host, profile: .workspace.profile}'

acceptance/auth/bundle_default_profile/test.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
Ignore = [
22
"home",
33
".databricks",
4-
"bundle-with-host",
5-
"bundle-with-profile",
4+
"databricks.yml",
65
]
76

87
# Negative case: -p other tries to reach a non-existing host. Redact the

0 commit comments

Comments
 (0)