From ae3801519458175c718040bbc445d1f7690bc8b9 Mon Sep 17 00:00:00 2001 From: "pavlo.kozlov" Date: Fri, 6 Nov 2026 14:03:22 +0000 Subject: [PATCH 01/10] Add .workspace.URLID and fix review findings on .workspace - Add .workspace.URLID: the workspace ID that .workspace.URL adds as ?w=, or empty. Unlike .workspace.ID, it doesn't fail when the ID is unknown and doesn't return an ID from host metadata. - Schema rendering keeps the default of an input that has a value when the default fails to render, instead of failing. bundle init doesn't use that default, so the same input works there. - Add setup_custom_host to acceptance/script.prepare for the test server reached as a host shared by several workspaces, and use it in workspace_variable. - The runtime test covers URLID per profile, a failing default of an input with a value, the w and workspace_id selectors and a protocol-relative path. - Doc comments name where URLID comes from, and the missing ID error names the bundle's workspace_id. Co-authored-by: Isaac --- .../bundles/workspace-template-urlid.md | 1 + .../runtime/input.protocol-relative.json | 1 + .../runtime/input.selector-w.json | 1 + .../runtime/input.selector-workspace-id.json | 1 + .../runtime/input.supplied.json | 1 + .../workspace_variable/runtime/output.txt | 42 +++++++++++++++- .../workspace_variable/runtime/script | 16 ++++-- .../supplied/databricks_template_schema.json | 9 ++++ .../runtime/supplied/template/value.txt.tmpl | 1 + .../runtime/urls/template/urls.txt.tmpl | 1 + .../workspace_variable/script.prepare | 7 +-- acceptance/script.prepare | 13 +++++ libs/template/schema_renderer.go | 5 ++ libs/template/workspace_context.go | 50 +++++++++++-------- libs/template/workspace_context_test.go | 2 +- 15 files changed, 118 insertions(+), 33 deletions(-) create mode 100644 .nextchanges/bundles/workspace-template-urlid.md create mode 100644 acceptance/bundle/templates-machinery/workspace_variable/runtime/input.protocol-relative.json create mode 100644 acceptance/bundle/templates-machinery/workspace_variable/runtime/input.selector-w.json create mode 100644 acceptance/bundle/templates-machinery/workspace_variable/runtime/input.selector-workspace-id.json create mode 100644 acceptance/bundle/templates-machinery/workspace_variable/runtime/input.supplied.json create mode 100644 acceptance/bundle/templates-machinery/workspace_variable/runtime/supplied/databricks_template_schema.json create mode 100644 acceptance/bundle/templates-machinery/workspace_variable/runtime/supplied/template/value.txt.tmpl diff --git a/.nextchanges/bundles/workspace-template-urlid.md b/.nextchanges/bundles/workspace-template-urlid.md new file mode 100644 index 00000000000..f5a8fbca631 --- /dev/null +++ b/.nextchanges/bundles/workspace-template-urlid.md @@ -0,0 +1 @@ +* Add `.workspace.URLID` to bundle templates: the workspace ID that `.workspace.URL` adds, or empty, so templates can use it without failing when the ID is unknown. ([#7388](https://github.com/databricks/cli/pull/7388)) diff --git a/acceptance/bundle/templates-machinery/workspace_variable/runtime/input.protocol-relative.json b/acceptance/bundle/templates-machinery/workspace_variable/runtime/input.protocol-relative.json new file mode 100644 index 00000000000..f31d8b9756a --- /dev/null +++ b/acceptance/bundle/templates-machinery/workspace_variable/runtime/input.protocol-relative.json @@ -0,0 +1 @@ +{"path": "//other.test/jobs"} diff --git a/acceptance/bundle/templates-machinery/workspace_variable/runtime/input.selector-w.json b/acceptance/bundle/templates-machinery/workspace_variable/runtime/input.selector-w.json new file mode 100644 index 00000000000..89f9c8c81ab --- /dev/null +++ b/acceptance/bundle/templates-machinery/workspace_variable/runtime/input.selector-w.json @@ -0,0 +1 @@ +{"path": "/jobs?w=123"} diff --git a/acceptance/bundle/templates-machinery/workspace_variable/runtime/input.selector-workspace-id.json b/acceptance/bundle/templates-machinery/workspace_variable/runtime/input.selector-workspace-id.json new file mode 100644 index 00000000000..9ab3ccc9fcc --- /dev/null +++ b/acceptance/bundle/templates-machinery/workspace_variable/runtime/input.selector-workspace-id.json @@ -0,0 +1 @@ +{"path": "/jobs?workspace_id=123"} diff --git a/acceptance/bundle/templates-machinery/workspace_variable/runtime/input.supplied.json b/acceptance/bundle/templates-machinery/workspace_variable/runtime/input.supplied.json new file mode 100644 index 00000000000..cb4e5d152c5 --- /dev/null +++ b/acceptance/bundle/templates-machinery/workspace_variable/runtime/input.supplied.json @@ -0,0 +1 @@ +{"value": "set by user"} diff --git a/acceptance/bundle/templates-machinery/workspace_variable/runtime/output.txt b/acceptance/bundle/templates-machinery/workspace_variable/runtime/output.txt index c6980cdead1..eec7fe20829 100644 --- a/acceptance/bundle/templates-machinery/workspace_variable/runtime/output.txt +++ b/acceptance/bundle/templates-machinery/workspace_variable/runtime/output.txt @@ -25,6 +25,7 @@ Hostname: [DATABRICKS_HOST] URL: [DATABRICKS_URL] URL "/jobs": [DATABRICKS_URL]/jobs URL "/jobs?view=list#top": [DATABRICKS_URL]/jobs?view=list#top +URLID: "" jobs_url: [DATABRICKS_URL]/jobs Root keys: jobs_url path workspace Root data: map[jobs_url:[DATABRICKS_URL]/jobs path:/jobs?view=list#top workspace:{[DATABRICKS_HOST] [DATABRICKS_URL] [WORKSPACE_ID] }] @@ -55,6 +56,7 @@ Hostname: [DATABRICKS_HOST] URL: [DATABRICKS_URL]?w=[WORKSPACE_ID] URL "/jobs": [DATABRICKS_URL]/jobs?w=[WORKSPACE_ID] URL "/jobs?view=list#top": [DATABRICKS_URL]/jobs?view=list&w=[WORKSPACE_ID]#top +URLID: "[WORKSPACE_ID]" jobs_url: [DATABRICKS_URL]/jobs?w=[WORKSPACE_ID] Root keys: jobs_url path workspace Root data: map[jobs_url:[DATABRICKS_URL]/jobs?w=[WORKSPACE_ID] path:/jobs?view=list#top workspace:{[DATABRICKS_HOST] [DATABRICKS_URL] [WORKSPACE_ID] [WORKSPACE_ID]}] @@ -85,6 +87,7 @@ Hostname: [CUSTOM_HOSTNAME] URL: [CUSTOM_HOST]?w=[WORKSPACE_ID] URL "/jobs": [CUSTOM_HOST]/jobs?w=[WORKSPACE_ID] URL "/jobs?view=list#top": [CUSTOM_HOST]/jobs?view=list&w=[WORKSPACE_ID]#top +URLID: "[WORKSPACE_ID]" jobs_url: [CUSTOM_HOST]/jobs?w=[WORKSPACE_ID] Root keys: jobs_url path workspace Root data: map[jobs_url:[CUSTOM_HOST]/jobs?w=[WORKSPACE_ID] path:/jobs?view=list#top workspace:{[CUSTOM_HOSTNAME] [CUSTOM_HOST] [WORKSPACE_ID] [WORKSPACE_ID]}] @@ -115,6 +118,7 @@ Hostname: [DATABRICKS_HOST] URL: [DATABRICKS_URL] URL "/jobs": [DATABRICKS_URL]/jobs URL "/jobs?view=list#top": [DATABRICKS_URL]/jobs?view=list#top +URLID: "" jobs_url: [DATABRICKS_URL]/jobs Root keys: jobs_url path workspace Root data: map[jobs_url:[DATABRICKS_URL]/jobs path:/jobs?view=list#top workspace:{[DATABRICKS_HOST] [DATABRICKS_URL] }] @@ -145,20 +149,54 @@ Hostname: [CUSTOM_HOSTNAME] URL: [CUSTOM_HOST]?w=[WORKSPACE_ID] URL "/jobs": [CUSTOM_HOST]/jobs?w=[WORKSPACE_ID] URL "/pipelines?tab=all": [CUSTOM_HOST]/pipelines?tab=all&w=[WORKSPACE_ID] +URLID: "[WORKSPACE_ID]" jobs_url: https://example.test/my-jobs Root keys: jobs_url path workspace Root data: map[jobs_url:https://example.test/my-jobs path:/pipelines?tab=all workspace:{[CUSTOM_HOSTNAME] [CUSTOM_HOST] [WORKSPACE_ID] [WORKSPACE_ID]}] +=== Failing default of an input with a value + +>>> [CLI] bundle debug render-template-schema ./supplied --profile no_workspace_id --input-file input.supplied.json +{ + "welcome_message": null, + "success_message": null, + "properties": { + "value": { + "description": "Value", + "default": "{{ .workspace.ID }}" + } + } +} + +>>> [CLI] bundle init ./supplied --profile no_workspace_id --config-file input.supplied.json +✨ Successfully initialized template +value: set by user + +>>> musterr [CLI] bundle debug render-template-schema ./supplied --profile no_workspace_id +Error: property value default: failed to render template "{{ .workspace.ID }}": template: base:1:13: executing "base" at <.workspace.ID>: error calling ID: cannot determine workspace ID, please set workspace_id in the configuration profile, the DATABRICKS_WORKSPACE_ID environment variable, or workspace.workspace_id in the bundle + === Invalid URL paths >>> musterr [CLI] bundle init ./urls --profile workspace_custom_host --config-file input.absolute-url.json Initializing for [CUSTOM_HOST]?w=[WORKSPACE_ID] Error: failed to compute file content for urls.txt.tmpl. template: :6:25: executing "" at <$ws.URL>: error calling URL: workspace URL path "https://other.test/jobs" must be relative to the workspace host +>>> musterr [CLI] bundle init ./urls --profile workspace_custom_host --config-file input.protocol-relative.json +Initializing for [CUSTOM_HOST]?w=[WORKSPACE_ID] +Error: failed to compute file content for urls.txt.tmpl. template: :6:25: executing "" at <$ws.URL>: error calling URL: workspace URL path "//other.test/jobs" must be relative to the workspace host + >>> musterr [CLI] bundle init ./urls --profile workspace_custom_host --config-file input.workspace-selector.json Initializing for [CUSTOM_HOST]?w=[WORKSPACE_ID] Error: failed to compute file content for urls.txt.tmpl. template: :6:25: executing "" at <$ws.URL>: error calling URL: workspace URL path "/jobs?o=123" must not set the "o" query parameter, the workspace is selected by the profile +>>> musterr [CLI] bundle init ./urls --profile workspace_custom_host --config-file input.selector-w.json +Initializing for [CUSTOM_HOST]?w=[WORKSPACE_ID] +Error: failed to compute file content for urls.txt.tmpl. template: :6:25: executing "" at <$ws.URL>: error calling URL: workspace URL path "/jobs?w=123" must not set the "w" query parameter, the workspace is selected by the profile + +>>> musterr [CLI] bundle init ./urls --profile workspace_custom_host --config-file input.selector-workspace-id.json +Initializing for [CUSTOM_HOST]?w=[WORKSPACE_ID] +Error: failed to compute file content for urls.txt.tmpl. template: :6:25: executing "" at <$ws.URL>: error calling URL: workspace URL path "/jobs?workspace_id=123" must not set the "workspace_id" query parameter, the workspace is selected by the profile + >>> musterr [CLI] bundle init ./urls --profile workspace_custom_host --config-file input.semicolon.json Initializing for [CUSTOM_HOST]?w=[WORKSPACE_ID] Error: failed to compute file content for urls.txt.tmpl. template: :6:25: executing "" at <$ws.URL>: error calling URL: failed to parse query of workspace URL path "/jobs?w=999;x=1": invalid semicolon separator in query @@ -171,6 +209,7 @@ Open [CUSTOM_HOST]/jobs?view=list&w=[WORKSPACE_ID]#top URL: [CUSTOM_HOST]?w=[WORKSPACE_ID] URL "/jobs": [CUSTOM_HOST]/jobs?w=[WORKSPACE_ID] URL "/jobs?view=list#top": [CUSTOM_HOST]/jobs?view=list&w=[WORKSPACE_ID]#top +URLID: "[WORKSPACE_ID]" === Workspace ID from the bundle in the working directory @@ -180,6 +219,7 @@ Open [DATABRICKS_URL]/jobs?view=list&w=[WORKSPACE_ID]#top URL: [DATABRICKS_URL]?w=[WORKSPACE_ID] URL "/jobs": [DATABRICKS_URL]/jobs?w=[WORKSPACE_ID] URL "/jobs?view=list#top": [DATABRICKS_URL]/jobs?view=list&w=[WORKSPACE_ID]#top +URLID: "[WORKSPACE_ID]" === ID @@ -192,6 +232,6 @@ ID: [WORKSPACE_ID] ID: [WORKSPACE_ID] >>> musterr [CLI] bundle init ./id --profile no_workspace_id -Error: failed to compute file content for id.txt.tmpl. template: :1:17: executing "" at <.workspace.ID>: error calling ID: cannot determine workspace ID, please set workspace_id in the configuration profile or the DATABRICKS_WORKSPACE_ID environment variable +Error: failed to compute file content for id.txt.tmpl. template: :1:17: executing "" at <.workspace.ID>: error calling ID: cannot determine workspace ID, please set workspace_id in the configuration profile, the DATABRICKS_WORKSPACE_ID environment variable, or workspace.workspace_id in the bundle >>> print_requests.py --get --oneline ^//telemetry-ext diff --git a/acceptance/bundle/templates-machinery/workspace_variable/runtime/script b/acceptance/bundle/templates-machinery/workspace_variable/runtime/script index 4a773ef943f..45e8bb48226 100644 --- a/acceptance/bundle/templates-machinery/workspace_variable/runtime/script +++ b/acceptance/bundle/templates-machinery/workspace_variable/runtime/script @@ -15,10 +15,20 @@ trace $CLI bundle init ./urls --profile workspace_custom_host --config-file inpu cat urls.txt rm urls.txt +# A default that fails, here because the profile has no workspace ID, doesn't +# matter when the input has a value: init doesn't use it, and the schema keeps +# it as written. Without a value, the schema still fails. +title "Failing default of an input with a value\n" +trace $CLI bundle debug render-template-schema ./supplied --profile no_workspace_id --input-file input.supplied.json | schema_fields +trace $CLI bundle init ./supplied --profile no_workspace_id --config-file input.supplied.json +cat value.txt +rm value.txt +trace musterr $CLI bundle debug render-template-schema ./supplied --profile no_workspace_id + title "Invalid URL paths\n" -trace musterr $CLI bundle init ./urls --profile workspace_custom_host --config-file input.absolute-url.json -trace musterr $CLI bundle init ./urls --profile workspace_custom_host --config-file input.workspace-selector.json -trace musterr $CLI bundle init ./urls --profile workspace_custom_host --config-file input.semicolon.json +for input in absolute-url protocol-relative workspace-selector selector-w selector-workspace-id semicolon; do + trace musterr $CLI bundle init ./urls --profile workspace_custom_host --config-file input.$input.json +done # No profile, so that only the environment variable sets the ID. title "Workspace ID from environment variables\n" diff --git a/acceptance/bundle/templates-machinery/workspace_variable/runtime/supplied/databricks_template_schema.json b/acceptance/bundle/templates-machinery/workspace_variable/runtime/supplied/databricks_template_schema.json new file mode 100644 index 00000000000..c5cef0564be --- /dev/null +++ b/acceptance/bundle/templates-machinery/workspace_variable/runtime/supplied/databricks_template_schema.json @@ -0,0 +1,9 @@ +{ + "properties": { + "value": { + "type": "string", + "description": "Value", + "default": "{{ .workspace.ID }}" + } + } +} diff --git a/acceptance/bundle/templates-machinery/workspace_variable/runtime/supplied/template/value.txt.tmpl b/acceptance/bundle/templates-machinery/workspace_variable/runtime/supplied/template/value.txt.tmpl new file mode 100644 index 00000000000..4c952daa4cf --- /dev/null +++ b/acceptance/bundle/templates-machinery/workspace_variable/runtime/supplied/template/value.txt.tmpl @@ -0,0 +1 @@ +value: {{ .value }} diff --git a/acceptance/bundle/templates-machinery/workspace_variable/runtime/urls/template/urls.txt.tmpl b/acceptance/bundle/templates-machinery/workspace_variable/runtime/urls/template/urls.txt.tmpl index 539714bfc4a..f5ca6fa67cc 100644 --- a/acceptance/bundle/templates-machinery/workspace_variable/runtime/urls/template/urls.txt.tmpl +++ b/acceptance/bundle/templates-machinery/workspace_variable/runtime/urls/template/urls.txt.tmpl @@ -4,6 +4,7 @@ Hostname: {{ .workspace.Hostname }} URL: {{ .workspace.URL }} URL "/jobs": {{ .workspace.URL "/jobs" }} URL "{{ .path }}": {{ $ws.URL .path }} +URLID: "{{ .workspace.URLID }}" jobs_url: {{ .jobs_url }} Root keys:{{ range $key, $value := . }} {{ $key }}{{ end }} Root data: {{ . }} diff --git a/acceptance/bundle/templates-machinery/workspace_variable/script.prepare b/acceptance/bundle/templates-machinery/workspace_variable/script.prepare index 531e2c9565e..ce84bfa6a19 100644 --- a/acceptance/bundle/templates-machinery/workspace_variable/script.prepare +++ b/acceptance/bundle/templates-machinery/workspace_variable/script.prepare @@ -1,9 +1,4 @@ -# The test server is reachable as both 127.0.0.1 and localhost. The second -# stands in for a host shared by several workspaces. -CUSTOM_HOST=${DATABRICKS_HOST/127.0.0.1/localhost} -add_repl "$CUSTOM_HOST" CUSTOM_HOST -add_repl "${CUSTOM_HOST#*://}" CUSTOM_HOSTNAME -WORKSPACE_ID=$(curl -s "$DATABRICKS_HOST/.well-known/databricks-config" | jq -r .workspace_id) +setup_custom_host # workspace_classic has no workspace_id, so the SDK resolves it from host # metadata. The "none" sentinel prevents that. diff --git a/acceptance/script.prepare b/acceptance/script.prepare index a53627b231d..e74b77d388d 100644 --- a/acceptance/script.prepare +++ b/acceptance/script.prepare @@ -115,6 +115,19 @@ add_repl() { env -u MSYS_NO_PATHCONV add_repl.py "$@" } +# setup_custom_host sets CUSTOM_HOST to the test server reached as localhost +# instead of 127.0.0.1, which stands in for a host shared by several workspaces, +# and WORKSPACE_ID to the workspace ID that the test server reports. Call it +# once per test, while DATABRICKS_HOST is still set: add_repl gives a repeated +# replacement name a suffix, so a second call adds duplicate replacements. +setup_custom_host() { + export CUSTOM_HOST=${DATABRICKS_HOST/127.0.0.1/localhost} + add_repl "$CUSTOM_HOST" CUSTOM_HOST + add_repl "${CUSTOM_HOST#*://}" CUSTOM_HOSTNAME + WORKSPACE_ID=$(curl -s "$DATABRICKS_HOST/.well-known/databricks-config" | jq -r .workspace_id) + export WORKSPACE_ID +} + nostamp() { # Same MSYS_NO_PATHCONV workaround as envsubst above: otherwise Python cannot # find nostamp.py on Windows. diff --git a/libs/template/schema_renderer.go b/libs/template/schema_renderer.go index d66dd7b47a1..0c389175b53 100644 --- a/libs/template/schema_renderer.go +++ b/libs/template/schema_renderer.go @@ -135,6 +135,11 @@ func RenderSchema(ctx context.Context, reader Reader, input RenderSchemaInput) ( if def, ok := prop["default"].(string); ok { rendered, err := renderString(def) if err != nil { + // bundle init doesn't use the default of an input that has a value, so it + // can't fail there. Keep the default as written instead of failing here. + if supplied { + continue + } return nil, fmt.Errorf("property %s default: %w", propName, err) } prop["default"] = rendered diff --git a/libs/template/workspace_context.go b/libs/template/workspace_context.go index 20bb5e5a5f8..8b430cfb209 100644 --- a/libs/template/workspace_context.go +++ b/libs/template/workspace_context.go @@ -35,7 +35,8 @@ var userSetWorkspaceIDSources = []sdkconfig.SourceType{ // it carries the workspace ID, which is required to address a workspace on a host shared by // several workspaces. // -// The fields are strings so that templates which print the root data get stable output. +// The fields are strings, not pointers, so that templates which print the root data with +// {{ . }} get the values instead of addresses. type workspaceContext struct { // Hostname is the workspace host without scheme, path, or query. It keeps the port if the // host has one. @@ -44,16 +45,22 @@ type workspaceContext struct { host string workspaceID string - // urlWorkspaceID is the workspace ID that URL adds as ?w=. It is empty unless the user set the - // ID. Strict profile matching (DATABRICKS_BUNDLE_STRICT_PROFILE_MATCH) compares the ID in the - // host with the profile's workspace_id, and a profile without workspace_id matches only a host - // without an ID. - urlWorkspaceID string + // URLID is the workspace ID that URL adds as ?w=. It is set when a workspace_id in the + // profile, DATABRICKS_WORKSPACE_ID, or the bundle's workspace_id sets the ID, and empty + // otherwise, so templates can check it without failing like ID does. It is empty for an ID + // that comes from ?o= in the profile's host or from host metadata. Strict profile matching + // (DATABRICKS_BUNDLE_STRICT_PROFILE_MATCH) compares the bundle's workspace ID, which comes + // from ?w= in its host, with the profile's workspace_id, and a profile without workspace_id + // matches only a bundle without an ID. + // + // It comes last so that templates which print the root data keep their output. + URLID string } -// loadWorkspaceContext returns the workspace context of the selected profile, or nil if the -// schema declares a workspace input. A declared input owns the name even before it has a value. -// Input values the schema doesn't declare don't claim the name, because bundle init ignores them. +// loadWorkspaceContext returns the workspace context of the resolved configuration, or nil +// if the schema declares a workspace input. A declared input owns the name even before it has +// a value. Input values the schema doesn't declare don't claim the name, because bundle init +// ignores them. func loadWorkspaceContext(ctx context.Context, schema *jsonschema.Schema) (*workspaceContext, error) { if _, ok := schema.Properties[workspaceVariable]; ok { return nil, nil @@ -67,15 +74,15 @@ func loadWorkspaceContext(ctx context.Context, schema *jsonschema.Schema) (*work if workspaceID == profile.WorkspaceIDNone { workspaceID = "" } - var urlWorkspaceID string + var urlID string if attr, ok := cfg.GetAuthDetails().Configuration["workspace_id"]; ok && slices.Contains(userSetWorkspaceIDSources, attr.Source.Type) { - urlWorkspaceID = workspaceID + urlID = workspaceID } return &workspaceContext{ - Hostname: host.Host, - host: cfg.Host, - workspaceID: workspaceID, - urlWorkspaceID: urlWorkspaceID, + Hostname: host.Host, + host: cfg.Host, + workspaceID: workspaceID, + URLID: urlID, }, nil } @@ -97,14 +104,13 @@ func templateData(values map[string]any, workspace *workspaceContext) map[string // shared by several workspaces. It doesn't make a request to discover the ID. func (c workspaceContext) ID() (string, error) { if c.workspaceID == "" { - return "", errors.New("cannot determine workspace ID, please set workspace_id in the configuration profile or the DATABRICKS_WORKSPACE_ID environment variable") + return "", errors.New("cannot determine workspace ID, please set workspace_id in the configuration profile, the DATABRICKS_WORKSPACE_ID environment variable, or workspace.workspace_id in the bundle") } return c.workspaceID, nil } // URL returns the workspace URL with an optional path relative to the workspace host, -// for example URL "/jobs". It adds ?w= when the profile, an environment variable, or the -// bundle sets the workspace ID. +// for example URL "/jobs". It adds ?w= when URLID is set. func (c workspaceContext) URL(path ...string) (string, error) { if len(path) > 1 { return "", fmt.Errorf("URL accepts at most one path, got %d", len(path)) @@ -113,11 +119,11 @@ func (c workspaceContext) URL(path ...string) (string, error) { if err != nil { return "", fmt.Errorf("failed to parse workspace host %q: %w", c.host, err) } - // Unlike workspaceurls.WorkspaceBaseURL, this adds ?w= also when the hostname has the ID - // (adb-), because strict profile matching reads the ID only from the query. - if c.urlWorkspaceID != "" { + // The workspaceurls package leaves out ?w= when the hostname has the ID (adb-). This + // adds it, because strict profile matching doesn't read the ID from the hostname. + if c.URLID != "" { query := base.Query() - query.Set("w", c.urlWorkspaceID) + query.Set("w", c.URLID) base.RawQuery = query.Encode() } if len(path) == 0 { diff --git a/libs/template/workspace_context_test.go b/libs/template/workspace_context_test.go index d20a45f621a..97016f138a3 100644 --- a/libs/template/workspace_context_test.go +++ b/libs/template/workspace_context_test.go @@ -87,7 +87,7 @@ func TestPromptForValuesWithWorkspace(t *testing.T) { // Acceptance tests can't use an adb- hostname, because the test server is reachable only // on localhost. func TestWorkspaceURLKeepsIDOnHostnameWithID(t *testing.T) { - ws := workspaceContext{host: "https://adb-111.4.azuredatabricks.net", workspaceID: "111", urlWorkspaceID: "111"} + ws := workspaceContext{host: "https://adb-111.4.azuredatabricks.net", workspaceID: "111", URLID: "111"} // Strict profile matching reads the ID from the query, not from the hostname. host, err := ws.URL() From 322640c107e54bf031ddb876293dc8d3ea896e8d Mon Sep 17 00:00:00 2001 From: "pavlo.kozlov" Date: Wed, 4 Nov 2026 15:41:10 +0000 Subject: [PATCH 02/10] Use .workspace.URL for the host in built-in templates Built-in templates, except dbt-sql, write the workspace URL to workspace.host. It has ?w= when the profile or an environment variable sets the workspace ID. Other profiles keep the same host as before. The value is quoted so the YAML stays valid for any URL. Template schemas keep workspace_host. Co-authored-by: Isaac --- .../builtin-templates-workspace-url.md | 1 + .../strict_profile_match/host/databricks.yml | 6 ++ .../strict_profile_match/host/output.txt | 8 +++ .../bundle/strict_profile_match/host/script | 2 +- .../extra-workspace-input/input.json | 5 ++ .../extra-workspace-input/out.test.toml | 2 + .../extra-workspace-input/output.txt | 17 +++++ .../extra-workspace-input/script | 5 ++ .../default-minimal/profiles/input.json | 4 ++ .../default-minimal/profiles/out.test.toml | 2 + .../default-minimal/profiles/output.txt | 68 +++++++++++++++++++ .../templates/default-minimal/profiles/script | 33 +++++++++ .../default-minimal/profiles/test.toml | 2 + .../output/my_default_minimal/databricks.yml | 4 +- .../output/my_default_minimal/databricks.yml | 4 +- .../output/my_default_minimal/databricks.yml | 4 +- .../output/my_default_python/databricks.yml | 4 +- .../serverless-customcatalog/output.txt | 2 +- .../output/my_default_python/databricks.yml | 4 +- .../output/my_default_scala/databricks.yml | 6 +- .../output/my_default_sql/databricks.yml | 4 +- .../out.default-python.databricks.yml | 4 +- .../my_lakeflow_integrations/databricks.yml | 4 +- .../my_lakeflow_pipelines/databricks.yml | 4 +- .../my_lakeflow_pipelines/databricks.yml | 4 +- .../output/my_pydabs/databricks.yml | 4 +- .../default-python/out.databricks.yml | 4 +- .../telemetry/default-sql/out.databricks.yml | 4 +- .../output/lakeflow_project/databricks.yml | 4 +- .../output/my_python_project/databricks.yml | 4 +- .../sql/output/my_sql_project/databricks.yml | 4 +- libs/template/renderer_test.go | 5 ++ .../{{.project_name}}/databricks.yml.tmpl | 6 +- .../{{.project_name}}/databricks.yml.tmpl | 4 +- .../{{.project_name}}/databricks.yml.tmpl | 4 +- .../{{.project_name}}/databricks.yml.tmpl | 4 +- 36 files changed, 204 insertions(+), 46 deletions(-) create mode 100644 .nextchanges/bundles/builtin-templates-workspace-url.md create mode 100644 acceptance/bundle/templates/default-minimal/extra-workspace-input/input.json create mode 100644 acceptance/bundle/templates/default-minimal/extra-workspace-input/out.test.toml create mode 100644 acceptance/bundle/templates/default-minimal/extra-workspace-input/output.txt create mode 100644 acceptance/bundle/templates/default-minimal/extra-workspace-input/script create mode 100644 acceptance/bundle/templates/default-minimal/profiles/input.json create mode 100644 acceptance/bundle/templates/default-minimal/profiles/out.test.toml create mode 100644 acceptance/bundle/templates/default-minimal/profiles/output.txt create mode 100644 acceptance/bundle/templates/default-minimal/profiles/script create mode 100644 acceptance/bundle/templates/default-minimal/profiles/test.toml diff --git a/.nextchanges/bundles/builtin-templates-workspace-url.md b/.nextchanges/bundles/builtin-templates-workspace-url.md new file mode 100644 index 00000000000..534ca9bd8c8 --- /dev/null +++ b/.nextchanges/bundles/builtin-templates-workspace-url.md @@ -0,0 +1 @@ +* Built-in templates (except `dbt-sql`) add the workspace ID to `workspace.host` (`?w=`) when the profile or an environment variable sets it, so generated bundles select the right workspace on hosts shared by several workspaces. ([#7350](https://github.com/databricks/cli/pull/7350)) diff --git a/acceptance/bundle/strict_profile_match/host/databricks.yml b/acceptance/bundle/strict_profile_match/host/databricks.yml index 5643f1b38c2..55cbbe1aae8 100644 --- a/acceptance/bundle/strict_profile_match/host/databricks.yml +++ b/acceptance/bundle/strict_profile_match/host/databricks.yml @@ -18,6 +18,12 @@ targets: custom_host: workspace: host: $CUSTOM_HOST/?o=$WORKSPACE_ID + classic_with_w: + workspace: + host: $CLASSIC_HOST?w=$WORKSPACE_ID + custom_host_with_w: + workspace: + host: $CUSTOM_HOST?w=$WORKSPACE_ID custom_host_workspace_id_field: workspace: host: $CUSTOM_HOST diff --git a/acceptance/bundle/strict_profile_match/host/output.txt b/acceptance/bundle/strict_profile_match/host/output.txt index 6c3dcbeefab..56cbb88faae 100644 --- a/acceptance/bundle/strict_profile_match/host/output.txt +++ b/acceptance/bundle/strict_profile_match/host/output.txt @@ -15,6 +15,14 @@ profile=workspace_custom_host host=[CUSTOM_HOST] workspace_id=[WORKSPACE_ID] >>> errcode [CLI] bundle run -t custom_host_workspace_id_field show_auth profile=workspace_custom_host host=[CUSTOM_HOST] workspace_id=[WORKSPACE_ID] +=== Target classic_with_w matches one profile +>>> errcode [CLI] bundle run -t classic_with_w show_auth +profile=workspace_classic_id host=[DATABRICKS_URL] workspace_id=[WORKSPACE_ID] + +=== Target custom_host_with_w matches one profile +>>> errcode [CLI] bundle run -t custom_host_with_w show_auth +profile=workspace_custom_host host=[CUSTOM_HOST] workspace_id=[WORKSPACE_ID] + === Target classic_other_workspace is rejected >>> errcode [CLI] bundle validate -t classic_other_workspace Error: cannot resolve bundle auth configuration: resolve: strict profile matching: no profile for host [DATABRICKS_URL] has workspace_id 2222222222. Config: host=[DATABRICKS_URL], workspace_id=2222222222, config_file=[TEST_TMP_DIR]/.databrickscfg, databricks_cli_path=[CLI]. Env: DATABRICKS_CONFIG_FILE, DATABRICKS_CLI_PATH diff --git a/acceptance/bundle/strict_profile_match/host/script b/acceptance/bundle/strict_profile_match/host/script index 1a5e32067eb..cac18599733 100644 --- a/acceptance/bundle/strict_profile_match/host/script +++ b/acceptance/bundle/strict_profile_match/host/script @@ -1,4 +1,4 @@ -for target in classic classic_with_workspace_id custom_host custom_host_workspace_id_field; do +for target in classic classic_with_workspace_id custom_host custom_host_workspace_id_field classic_with_w custom_host_with_w; do title "Target $target matches one profile" trace errcode $CLI bundle run -t $target show_auth done diff --git a/acceptance/bundle/templates/default-minimal/extra-workspace-input/input.json b/acceptance/bundle/templates/default-minimal/extra-workspace-input/input.json new file mode 100644 index 00000000000..0b2cdd03139 --- /dev/null +++ b/acceptance/bundle/templates/default-minimal/extra-workspace-input/input.json @@ -0,0 +1,5 @@ +{ + "project_name": "my_default_minimal", + "language_choice": "python", + "workspace": "team-dev" +} diff --git a/acceptance/bundle/templates/default-minimal/extra-workspace-input/out.test.toml b/acceptance/bundle/templates/default-minimal/extra-workspace-input/out.test.toml new file mode 100644 index 00000000000..19b5b15d11f --- /dev/null +++ b/acceptance/bundle/templates/default-minimal/extra-workspace-input/out.test.toml @@ -0,0 +1,2 @@ +Cloud = false +EnvMatrix.DMS = [""] diff --git a/acceptance/bundle/templates/default-minimal/extra-workspace-input/output.txt b/acceptance/bundle/templates/default-minimal/extra-workspace-input/output.txt new file mode 100644 index 00000000000..dc72ad846ae --- /dev/null +++ b/acceptance/bundle/templates/default-minimal/extra-workspace-input/output.txt @@ -0,0 +1,17 @@ + +>>> [CLI] bundle init default-minimal --config-file ./input.json +Welcome to the minimal Declarative Automation Bundle template! + +This template creates a minimal project structure without sample code, ideal for advanced users. +(For getting started with Python or SQL code, use the default-python or default-sql templates instead.) + +Your workspace at [DATABRICKS_URL] is used for initialization. +(See https://docs.databricks.com/dev-tools/cli/profiles.html for how to change your profile.) + +✨ Your new project has been created in the 'my_default_minimal' directory! + +To get started, refer to the project README.md file and the documentation at https://docs.databricks.com/dev-tools/bundles/index.html. + +>>> grep host: my_default_minimal/databricks.yml + host: "[DATABRICKS_URL]" + host: "[DATABRICKS_URL]" diff --git a/acceptance/bundle/templates/default-minimal/extra-workspace-input/script b/acceptance/bundle/templates/default-minimal/extra-workspace-input/script new file mode 100644 index 00000000000..e01fbd1a2f6 --- /dev/null +++ b/acceptance/bundle/templates/default-minimal/extra-workspace-input/script @@ -0,0 +1,5 @@ +# The template doesn't declare a workspace input, so the extra key is ignored +# and the template still gets the workspace context. +trace $CLI bundle init default-minimal --config-file ./input.json +trace grep 'host:' my_default_minimal/databricks.yml +rm -r my_default_minimal diff --git a/acceptance/bundle/templates/default-minimal/profiles/input.json b/acceptance/bundle/templates/default-minimal/profiles/input.json new file mode 100644 index 00000000000..c620c3159b5 --- /dev/null +++ b/acceptance/bundle/templates/default-minimal/profiles/input.json @@ -0,0 +1,4 @@ +{ + "project_name": "my_default_minimal", + "language_choice": "python" +} diff --git a/acceptance/bundle/templates/default-minimal/profiles/out.test.toml b/acceptance/bundle/templates/default-minimal/profiles/out.test.toml new file mode 100644 index 00000000000..19b5b15d11f --- /dev/null +++ b/acceptance/bundle/templates/default-minimal/profiles/out.test.toml @@ -0,0 +1,2 @@ +Cloud = false +EnvMatrix.DMS = [""] diff --git a/acceptance/bundle/templates/default-minimal/profiles/output.txt b/acceptance/bundle/templates/default-minimal/profiles/output.txt new file mode 100644 index 00000000000..0e6af63730a --- /dev/null +++ b/acceptance/bundle/templates/default-minimal/profiles/output.txt @@ -0,0 +1,68 @@ + +=== Profile classic + +>>> [CLI] bundle init default-minimal --config-file ./input.json --profile classic +Welcome to the minimal Declarative Automation Bundle template! + +This template creates a minimal project structure without sample code, ideal for advanced users. +(For getting started with Python or SQL code, use the default-python or default-sql templates instead.) + +Your workspace at [DATABRICKS_URL] is used for initialization. +(See https://docs.databricks.com/dev-tools/cli/profiles.html for how to change your profile.) + +✨ Your new project has been created in the 'my_default_minimal' directory! + +To get started, refer to the project README.md file and the documentation at https://docs.databricks.com/dev-tools/bundles/index.html. + +>>> grep host: databricks.yml + host: "[DATABRICKS_URL]" + host: "[DATABRICKS_URL]" + +>>> DATABRICKS_BUNDLE_STRICT_PROFILE_MATCH=1 [CLI] bundle validate -t dev +Name: my_default_minimal +Target: dev +Workspace: + Host: [DATABRICKS_URL] + User: [USERNAME] + Path: /Workspace/Users/[USERNAME]/.bundle/my_default_minimal/dev + +Validation OK! + +>>> [CLI] bundle deploy -t dev +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/my_default_minimal/dev/files... +Files: 10 uploaded, 0 deleted +Resources: 0 created, 0 changed, 0 deleted, 0 unchanged + +=== Profile custom_host + +>>> [CLI] bundle init default-minimal --config-file ./input.json --profile custom_host +Welcome to the minimal Declarative Automation Bundle template! + +This template creates a minimal project structure without sample code, ideal for advanced users. +(For getting started with Python or SQL code, use the default-python or default-sql templates instead.) + +Your workspace at [CUSTOM_HOST] is used for initialization. +(See https://docs.databricks.com/dev-tools/cli/profiles.html for how to change your profile.) + +✨ Your new project has been created in the 'my_default_minimal' directory! + +To get started, refer to the project README.md file and the documentation at https://docs.databricks.com/dev-tools/bundles/index.html. + +>>> grep host: databricks.yml + host: "[CUSTOM_HOST]?w=[WORKSPACE_ID]" + host: "[CUSTOM_HOST]?w=[WORKSPACE_ID]" + +>>> DATABRICKS_BUNDLE_STRICT_PROFILE_MATCH=1 [CLI] bundle validate -t dev +Name: my_default_minimal +Target: dev +Workspace: + Host: [CUSTOM_HOST]?w=[WORKSPACE_ID] + User: [USERNAME] + Path: /Workspace/Users/[USERNAME]/.bundle/my_default_minimal/dev + +Validation OK! + +>>> [CLI] bundle deploy -t dev +Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/my_default_minimal/dev/files... +Files: 10 uploaded, 0 deleted +Resources: 0 created, 0 changed, 0 deleted, 0 unchanged diff --git a/acceptance/bundle/templates/default-minimal/profiles/script b/acceptance/bundle/templates/default-minimal/profiles/script new file mode 100644 index 00000000000..00a3795fdaf --- /dev/null +++ b/acceptance/bundle/templates/default-minimal/profiles/script @@ -0,0 +1,33 @@ +# The test server is reachable as both 127.0.0.1 and localhost. The second +# stands in for a host shared by several workspaces. +CUSTOM_HOST=${DATABRICKS_HOST/127.0.0.1/localhost} +add_repl "$CUSTOM_HOST" CUSTOM_HOST +WORKSPACE_ID=$(curl -s "$DATABRICKS_HOST/.well-known/databricks-config" | jq -r .workspace_id) + +# The classic profile has no workspace_id. The SDK resolves the ID from host +# metadata, but the generated host stays without ?w= so that it matches the +# profile in strict mode too. +cat > .databrickscfg < Date: Wed, 4 Nov 2026 16:47:59 +0000 Subject: [PATCH 03/10] Show .workspace.URL in the welcome messages of built-in templates The welcome messages showed workspace_host, which has no workspace ID. They now show the URL that the bundle uses, so they match workspace.host in the generated databricks.yml. Messages that printed "workspace_host:" now print "workspace_url:". Co-authored-by: Isaac --- acceptance/bundle/templates/dbt-sql-classic/output.txt | 2 +- acceptance/bundle/templates/dbt-sql/output.txt | 2 +- .../bundle/templates/default-minimal/profiles/output.txt | 2 +- .../bundle/templates/default-scala-classic/output.txt | 2 +- acceptance/bundle/templates/default-scala/output.txt | 2 +- .../bundle/templates/default-sql-catalog-dash/output.txt | 2 +- acceptance/bundle/templates/default-sql/output.txt | 2 +- acceptance/bundle/templates/deployment-history/output.txt | 6 +++--- acceptance/bundle/templates/telemetry/dbt-sql/output.txt | 2 +- .../bundle/templates/telemetry/default-sql/output.txt | 2 +- .../templates/dbt-sql/databricks_template_schema.json | 2 +- .../default-minimal/databricks_template_schema.json | 2 +- .../default-python/databricks_template_schema.json | 2 +- .../templates/default-scala/databricks_template_schema.json | 2 +- .../templates/default-sql/databricks_template_schema.json | 2 +- .../lakeflow-pipelines/databricks_template_schema.json | 2 +- .../templates/pydabs/databricks_template_schema.json | 2 +- 17 files changed, 19 insertions(+), 19 deletions(-) diff --git a/acceptance/bundle/templates/dbt-sql-classic/output.txt b/acceptance/bundle/templates/dbt-sql-classic/output.txt index 66c5cf492e0..9d9c3dd15e4 100644 --- a/acceptance/bundle/templates/dbt-sql-classic/output.txt +++ b/acceptance/bundle/templates/dbt-sql-classic/output.txt @@ -4,7 +4,7 @@ Welcome to the dbt template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_host: [DATABRICKS_URL] +workspace_url: [DATABRICKS_URL] 📊 Your new project has been created in the 'my_dbt_sql' directory! If you already have dbt installed, just type 'cd my_dbt_sql; dbt init' to get started. diff --git a/acceptance/bundle/templates/dbt-sql/output.txt b/acceptance/bundle/templates/dbt-sql/output.txt index 8555f15292c..340d69955a2 100644 --- a/acceptance/bundle/templates/dbt-sql/output.txt +++ b/acceptance/bundle/templates/dbt-sql/output.txt @@ -4,7 +4,7 @@ Welcome to the dbt template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_host: [DATABRICKS_URL] +workspace_url: [DATABRICKS_URL] 📊 Your new project has been created in the 'my_dbt_sql' directory! If you already have dbt installed, just type 'cd my_dbt_sql; dbt init' to get started. diff --git a/acceptance/bundle/templates/default-minimal/profiles/output.txt b/acceptance/bundle/templates/default-minimal/profiles/output.txt index 0e6af63730a..3bbc918ef62 100644 --- a/acceptance/bundle/templates/default-minimal/profiles/output.txt +++ b/acceptance/bundle/templates/default-minimal/profiles/output.txt @@ -41,7 +41,7 @@ Welcome to the minimal Declarative Automation Bundle template! This template creates a minimal project structure without sample code, ideal for advanced users. (For getting started with Python or SQL code, use the default-python or default-sql templates instead.) -Your workspace at [CUSTOM_HOST] is used for initialization. +Your workspace at [CUSTOM_HOST]?w=[WORKSPACE_ID] is used for initialization. (See https://docs.databricks.com/dev-tools/cli/profiles.html for how to change your profile.) ✨ Your new project has been created in the 'my_default_minimal' directory! diff --git a/acceptance/bundle/templates/default-scala-classic/output.txt b/acceptance/bundle/templates/default-scala-classic/output.txt index 6ceb22ee71b..f6649f78380 100644 --- a/acceptance/bundle/templates/default-scala-classic/output.txt +++ b/acceptance/bundle/templates/default-scala-classic/output.txt @@ -4,7 +4,7 @@ Welcome to the default-scala template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_host: [DATABRICKS_URL] +workspace_url: [DATABRICKS_URL] ✨ Your new project has been created in the 'my_default_scala' directory! diff --git a/acceptance/bundle/templates/default-scala/output.txt b/acceptance/bundle/templates/default-scala/output.txt index 8a4f23f5a32..3d43242bc4e 100644 --- a/acceptance/bundle/templates/default-scala/output.txt +++ b/acceptance/bundle/templates/default-scala/output.txt @@ -4,7 +4,7 @@ Welcome to the default-scala template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_host: [DATABRICKS_URL] +workspace_url: [DATABRICKS_URL] ✨ Your new project has been created in the 'my_default_scala' directory! diff --git a/acceptance/bundle/templates/default-sql-catalog-dash/output.txt b/acceptance/bundle/templates/default-sql-catalog-dash/output.txt index 23a18c5d02c..85c1ebf6e27 100644 --- a/acceptance/bundle/templates/default-sql-catalog-dash/output.txt +++ b/acceptance/bundle/templates/default-sql-catalog-dash/output.txt @@ -4,7 +4,7 @@ Welcome to the default SQL template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_host: [DATABRICKS_URL] +workspace_url: [DATABRICKS_URL] ✨ Your new project has been created in the 'my_default_sql' directory! diff --git a/acceptance/bundle/templates/default-sql/output.txt b/acceptance/bundle/templates/default-sql/output.txt index 222e5d7e1e6..6dde88fb158 100644 --- a/acceptance/bundle/templates/default-sql/output.txt +++ b/acceptance/bundle/templates/default-sql/output.txt @@ -4,7 +4,7 @@ Welcome to the default SQL template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_host: [DATABRICKS_URL] +workspace_url: [DATABRICKS_URL] ✨ Your new project has been created in the 'my_default_sql' directory! diff --git a/acceptance/bundle/templates/deployment-history/output.txt b/acceptance/bundle/templates/deployment-history/output.txt index a6f06bdcb77..c9f9febde46 100644 --- a/acceptance/bundle/templates/deployment-history/output.txt +++ b/acceptance/bundle/templates/deployment-history/output.txt @@ -17,7 +17,7 @@ experimental: Welcome to the default SQL template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_host: [DATABRICKS_URL] +workspace_url: [DATABRICKS_URL] ✨ Your new project has been created in the 'my_default_sql' directory! @@ -31,7 +31,7 @@ experimental: Welcome to the default-scala template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_host: [DATABRICKS_URL] +workspace_url: [DATABRICKS_URL] ✨ Your new project has been created in the 'my_default_scala' directory! @@ -45,7 +45,7 @@ experimental: Welcome to the dbt template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_host: [DATABRICKS_URL] +workspace_url: [DATABRICKS_URL] 📊 Your new project has been created in the 'my_dbt_sql' directory! If you already have dbt installed, just type 'cd my_dbt_sql; dbt init' to get started. diff --git a/acceptance/bundle/templates/telemetry/dbt-sql/output.txt b/acceptance/bundle/templates/telemetry/dbt-sql/output.txt index 74e0bac9312..606fd91719e 100644 --- a/acceptance/bundle/templates/telemetry/dbt-sql/output.txt +++ b/acceptance/bundle/templates/telemetry/dbt-sql/output.txt @@ -2,7 +2,7 @@ Welcome to the dbt template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_host: [DATABRICKS_URL] +workspace_url: [DATABRICKS_URL] 📊 Your new project has been created in the 'my_dbt_sql' directory! If you already have dbt installed, just type 'cd my_dbt_sql; dbt init' to get started. diff --git a/acceptance/bundle/templates/telemetry/default-sql/output.txt b/acceptance/bundle/templates/telemetry/default-sql/output.txt index 775d86933af..67ebb78d0e9 100644 --- a/acceptance/bundle/templates/telemetry/default-sql/output.txt +++ b/acceptance/bundle/templates/telemetry/default-sql/output.txt @@ -2,7 +2,7 @@ Welcome to the default SQL template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_host: [DATABRICKS_URL] +workspace_url: [DATABRICKS_URL] ✨ Your new project has been created in the 'my_default_sql' directory! diff --git a/libs/template/templates/dbt-sql/databricks_template_schema.json b/libs/template/templates/dbt-sql/databricks_template_schema.json index 17c93ca76e0..15cae9ae393 100644 --- a/libs/template/templates/dbt-sql/databricks_template_schema.json +++ b/libs/template/templates/dbt-sql/databricks_template_schema.json @@ -1,5 +1,5 @@ { - "welcome_message": "\nWelcome to the dbt template for Declarative Automation Bundles!\n\nA workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html.\nworkspace_host: {{workspace_host}}", + "welcome_message": "\nWelcome to the dbt template for Declarative Automation Bundles!\n\nA workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html.\nworkspace_url: {{.workspace.URL}}", "properties": { "project_name": { "type": "string", diff --git a/libs/template/templates/default-minimal/databricks_template_schema.json b/libs/template/templates/default-minimal/databricks_template_schema.json index 0935684256b..b8df334a017 100644 --- a/libs/template/templates/default-minimal/databricks_template_schema.json +++ b/libs/template/templates/default-minimal/databricks_template_schema.json @@ -1,6 +1,6 @@ { "template_dir": "../default", - "welcome_message": "Welcome to the minimal Declarative Automation Bundle template!\n\nThis template creates a minimal project structure without sample code, ideal for advanced users.\n(For getting started with Python or SQL code, use the default-python or default-sql templates instead.)\n\nYour workspace at {{workspace_host}} is used for initialization.\n(See https://docs.databricks.com/dev-tools/cli/profiles.html for how to change your profile.)", + "welcome_message": "Welcome to the minimal Declarative Automation Bundle template!\n\nThis template creates a minimal project structure without sample code, ideal for advanced users.\n(For getting started with Python or SQL code, use the default-python or default-sql templates instead.)\n\nYour workspace at {{.workspace.URL}} is used for initialization.\n(See https://docs.databricks.com/dev-tools/cli/profiles.html for how to change your profile.)", "properties": { "template_name": { "//": "This property is always set to 'default-minimal'", diff --git a/libs/template/templates/default-python/databricks_template_schema.json b/libs/template/templates/default-python/databricks_template_schema.json index d8d5e485ced..e9e61f4a924 100644 --- a/libs/template/templates/default-python/databricks_template_schema.json +++ b/libs/template/templates/default-python/databricks_template_schema.json @@ -1,6 +1,6 @@ { "template_dir": "../default", - "welcome_message": "Welcome to the default Python template for Declarative Automation Bundles!\n\nAnswer the following questions to customize your project.\nYou can always change your configuration in the databricks.yml file later.\n\nNote that {{workspace_host}} is used for initialization.\n(For information on how to change your profile, see https://docs.databricks.com/dev-tools/cli/profiles.html.)", + "welcome_message": "Welcome to the default Python template for Declarative Automation Bundles!\n\nAnswer the following questions to customize your project.\nYou can always change your configuration in the databricks.yml file later.\n\nNote that {{.workspace.URL}} is used for initialization.\n(For information on how to change your profile, see https://docs.databricks.com/dev-tools/cli/profiles.html.)", "properties": { "template_name": { "//": "This property is always set to 'default-python'", diff --git a/libs/template/templates/default-scala/databricks_template_schema.json b/libs/template/templates/default-scala/databricks_template_schema.json index 9501c56196d..2a9e5cc72a4 100644 --- a/libs/template/templates/default-scala/databricks_template_schema.json +++ b/libs/template/templates/default-scala/databricks_template_schema.json @@ -1,5 +1,5 @@ { - "welcome_message": "\nWelcome to the default-scala template for Declarative Automation Bundles!\n\nA workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html.\nworkspace_host: {{workspace_host}}", + "welcome_message": "\nWelcome to the default-scala template for Declarative Automation Bundles!\n\nA workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html.\nworkspace_url: {{.workspace.URL}}", "properties": { "project_name": { "type": "string", diff --git a/libs/template/templates/default-sql/databricks_template_schema.json b/libs/template/templates/default-sql/databricks_template_schema.json index c6f66d495a8..2fc7e31ec15 100644 --- a/libs/template/templates/default-sql/databricks_template_schema.json +++ b/libs/template/templates/default-sql/databricks_template_schema.json @@ -1,5 +1,5 @@ { - "welcome_message": "\nWelcome to the default SQL template for Declarative Automation Bundles!\n\nA workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html.\nworkspace_host: {{workspace_host}}", + "welcome_message": "\nWelcome to the default SQL template for Declarative Automation Bundles!\n\nA workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html.\nworkspace_url: {{.workspace.URL}}", "properties": { "project_name": { "type": "string", diff --git a/libs/template/templates/lakeflow-pipelines/databricks_template_schema.json b/libs/template/templates/lakeflow-pipelines/databricks_template_schema.json index 8639acc49e9..ddd17278829 100644 --- a/libs/template/templates/lakeflow-pipelines/databricks_template_schema.json +++ b/libs/template/templates/lakeflow-pipelines/databricks_template_schema.json @@ -1,6 +1,6 @@ { "template_dir": "../default", - "welcome_message": "Welcome to the template for Lakeflow Spark Declarative Pipelines!\n\nPlease answer the below to tailor your project to your preferences.\nYou can always change your mind and change your configuration in the databricks.yml file later.\n\nNote that {{workspace_host}} is used for initialization\n(see https://docs.databricks.com/dev-tools/cli/profiles.html for how to change your profile).", + "welcome_message": "Welcome to the template for Lakeflow Spark Declarative Pipelines!\n\nPlease answer the below to tailor your project to your preferences.\nYou can always change your mind and change your configuration in the databricks.yml file later.\n\nNote that {{.workspace.URL}} is used for initialization\n(see https://docs.databricks.com/dev-tools/cli/profiles.html for how to change your profile).", "properties": { "template_name": { "//": "This property is always set to 'lakeflow-pipelines'", diff --git a/libs/template/templates/pydabs/databricks_template_schema.json b/libs/template/templates/pydabs/databricks_template_schema.json index 4819b5bb773..d53f8ba85cc 100644 --- a/libs/template/templates/pydabs/databricks_template_schema.json +++ b/libs/template/templates/pydabs/databricks_template_schema.json @@ -1,6 +1,6 @@ { "template_dir": "../default", - "welcome_message": "Welcome to PyDABs template for Declarative Automation Bundles!\n\nAnswer the following questions to customize your project.\nYou can always change your configuration in the databricks.yml file later.\n\nNote that {{workspace_host}} is used for initialization.\n(For information on how to change your profile, see https://docs.databricks.com/dev-tools/cli/profiles.html.)", + "welcome_message": "Welcome to PyDABs template for Declarative Automation Bundles!\n\nAnswer the following questions to customize your project.\nYou can always change your configuration in the databricks.yml file later.\n\nNote that {{.workspace.URL}} is used for initialization.\n(For information on how to change your profile, see https://docs.databricks.com/dev-tools/cli/profiles.html.)", "properties": { "template_name": { "//": "This property is always set to 'PyDABs'", From cabcf65cf57a3d68702e074d28e3280afae52b96 Mon Sep 17 00:00:00 2001 From: "pavlo.kozlov" Date: Wed, 4 Nov 2026 16:55:41 +0000 Subject: [PATCH 04/10] Use .workspace in the dbt-sql template The bundle host now comes from .workspace.URL like in the other built-in templates. dbt jobs get their host from Databricks, so they are not affected. The dbt profile default uses .workspace.Hostname, which gives the same value as stripping the scheme from workspace_host. No built-in template uses workspace_host now. Co-authored-by: Isaac --- .nextchanges/bundles/builtin-templates-workspace-url.md | 2 +- .../bundle/templates/dbt-sql/output/my_dbt_sql/databricks.yml | 4 ++-- .../bundle/templates/telemetry/dbt-sql/out.databricks.yml | 4 ++-- .../dbt-sql/template/{{.project_name}}/databricks.yml.tmpl | 4 ++-- .../template/{{.project_name}}/profile_template.yml.tmpl | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.nextchanges/bundles/builtin-templates-workspace-url.md b/.nextchanges/bundles/builtin-templates-workspace-url.md index 534ca9bd8c8..230f2be6513 100644 --- a/.nextchanges/bundles/builtin-templates-workspace-url.md +++ b/.nextchanges/bundles/builtin-templates-workspace-url.md @@ -1 +1 @@ -* Built-in templates (except `dbt-sql`) add the workspace ID to `workspace.host` (`?w=`) when the profile or an environment variable sets it, so generated bundles select the right workspace on hosts shared by several workspaces. ([#7350](https://github.com/databricks/cli/pull/7350)) +* Built-in templates add the workspace ID to `workspace.host` (`?w=`) when the profile or an environment variable sets it, so generated bundles select the right workspace on hosts shared by several workspaces. Their welcome messages show the same URL. ([#7350](https://github.com/databricks/cli/pull/7350)) diff --git a/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/databricks.yml b/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/databricks.yml index 5f2a8cd93b0..8e4aabcebb3 100644 --- a/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/databricks.yml +++ b/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/databricks.yml @@ -19,12 +19,12 @@ targets: mode: development default: true workspace: - host: [DATABRICKS_URL] + host: "[DATABRICKS_URL]" prod: mode: production workspace: - host: [DATABRICKS_URL] + host: "[DATABRICKS_URL]" # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} permissions: diff --git a/acceptance/bundle/templates/telemetry/dbt-sql/out.databricks.yml b/acceptance/bundle/templates/telemetry/dbt-sql/out.databricks.yml index d4e7a980b0b..a4c3028ffa4 100644 --- a/acceptance/bundle/templates/telemetry/dbt-sql/out.databricks.yml +++ b/acceptance/bundle/templates/telemetry/dbt-sql/out.databricks.yml @@ -19,12 +19,12 @@ targets: mode: development default: true workspace: - host: [DATABRICKS_URL] + host: "[DATABRICKS_URL]" prod: mode: production workspace: - host: [DATABRICKS_URL] + host: "[DATABRICKS_URL]" # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} permissions: diff --git a/libs/template/templates/dbt-sql/template/{{.project_name}}/databricks.yml.tmpl b/libs/template/templates/dbt-sql/template/{{.project_name}}/databricks.yml.tmpl index 21c82234a83..fd41553f4ad 100644 --- a/libs/template/templates/dbt-sql/template/{{.project_name}}/databricks.yml.tmpl +++ b/libs/template/templates/dbt-sql/template/{{.project_name}}/databricks.yml.tmpl @@ -20,12 +20,12 @@ targets: mode: development default: true workspace: - host: {{workspace_host}} + host: "{{.workspace.URL}}" prod: mode: production workspace: - host: {{workspace_host}} + host: "{{.workspace.URL}}" # We explicitly deploy to /Workspace/Users/{{user_name}} to make sure we only have a single copy. root_path: /Workspace/Users/{{user_name}}/.bundle/${bundle.name}/${bundle.target} permissions: diff --git a/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl b/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl index 1bab573f2fa..57e56e2d27b 100644 --- a/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl +++ b/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl @@ -5,7 +5,7 @@ fixed: type: databricks prompts: host: - default: {{(regexp "^https?://").ReplaceAllString workspace_host ""}} + default: {{.workspace.Hostname}} token: hint: 'personal access token to use, dapiXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' hide_input: true From 4710000dc3ad96b5e3510960ff4f4bc8bab47329 Mon Sep 17 00:00:00 2001 From: "pavlo.kozlov" Date: Wed, 4 Nov 2026 17:18:13 +0000 Subject: [PATCH 05/10] Update dbt-sql output for .workspace.Hostname without the port The dbt profile default no longer has the port of the test server. Databricks hosts don't have an explicit port, so for them the default is the same as before. Co-authored-by: Isaac --- .../templates/dbt-sql/output/my_dbt_sql/profile_template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/profile_template.yml b/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/profile_template.yml index bdb41ab202e..49b872b6d55 100644 --- a/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/profile_template.yml +++ b/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/profile_template.yml @@ -5,7 +5,7 @@ fixed: type: databricks prompts: host: - default: [DATABRICKS_HOST] + default: 127.0.0.1 token: hint: 'personal access token to use, dapiXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' hide_input: true From bb816f442e893e5f198f151c4b9f8eb652aaa81f Mon Sep 17 00:00:00 2001 From: "pavlo.kozlov" Date: Thu, 5 Nov 2026 09:17:02 +0000 Subject: [PATCH 06/10] Keep workspace_host in the dbt-sql template dbt-sql keeps workspace_host for its bundle host and its dbt profile default until we check that dbt accepts the new host format. This reverts 78cc12216 and c6c9291d8. Its welcome message still shows .workspace.URL like the other built-in templates. Co-authored-by: Isaac --- .nextchanges/bundles/builtin-templates-workspace-url.md | 2 +- .../bundle/templates/dbt-sql/output/my_dbt_sql/databricks.yml | 4 ++-- .../templates/dbt-sql/output/my_dbt_sql/profile_template.yml | 2 +- .../bundle/templates/telemetry/dbt-sql/out.databricks.yml | 4 ++-- .../dbt-sql/template/{{.project_name}}/databricks.yml.tmpl | 4 ++-- .../template/{{.project_name}}/profile_template.yml.tmpl | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.nextchanges/bundles/builtin-templates-workspace-url.md b/.nextchanges/bundles/builtin-templates-workspace-url.md index 230f2be6513..cb97fad3984 100644 --- a/.nextchanges/bundles/builtin-templates-workspace-url.md +++ b/.nextchanges/bundles/builtin-templates-workspace-url.md @@ -1 +1 @@ -* Built-in templates add the workspace ID to `workspace.host` (`?w=`) when the profile or an environment variable sets it, so generated bundles select the right workspace on hosts shared by several workspaces. Their welcome messages show the same URL. ([#7350](https://github.com/databricks/cli/pull/7350)) +* Built-in templates (except `dbt-sql`) add the workspace ID to `workspace.host` (`?w=`) when the profile or an environment variable sets it, so generated bundles select the right workspace on hosts shared by several workspaces. Welcome messages of all built-in templates show the workspace URL. ([#7350](https://github.com/databricks/cli/pull/7350)) diff --git a/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/databricks.yml b/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/databricks.yml index 8e4aabcebb3..5f2a8cd93b0 100644 --- a/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/databricks.yml +++ b/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/databricks.yml @@ -19,12 +19,12 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} permissions: diff --git a/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/profile_template.yml b/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/profile_template.yml index 49b872b6d55..bdb41ab202e 100644 --- a/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/profile_template.yml +++ b/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/profile_template.yml @@ -5,7 +5,7 @@ fixed: type: databricks prompts: host: - default: 127.0.0.1 + default: [DATABRICKS_HOST] token: hint: 'personal access token to use, dapiXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' hide_input: true diff --git a/acceptance/bundle/templates/telemetry/dbt-sql/out.databricks.yml b/acceptance/bundle/templates/telemetry/dbt-sql/out.databricks.yml index a4c3028ffa4..d4e7a980b0b 100644 --- a/acceptance/bundle/templates/telemetry/dbt-sql/out.databricks.yml +++ b/acceptance/bundle/templates/telemetry/dbt-sql/out.databricks.yml @@ -19,12 +19,12 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} permissions: diff --git a/libs/template/templates/dbt-sql/template/{{.project_name}}/databricks.yml.tmpl b/libs/template/templates/dbt-sql/template/{{.project_name}}/databricks.yml.tmpl index fd41553f4ad..21c82234a83 100644 --- a/libs/template/templates/dbt-sql/template/{{.project_name}}/databricks.yml.tmpl +++ b/libs/template/templates/dbt-sql/template/{{.project_name}}/databricks.yml.tmpl @@ -20,12 +20,12 @@ targets: mode: development default: true workspace: - host: "{{.workspace.URL}}" + host: {{workspace_host}} prod: mode: production workspace: - host: "{{.workspace.URL}}" + host: {{workspace_host}} # We explicitly deploy to /Workspace/Users/{{user_name}} to make sure we only have a single copy. root_path: /Workspace/Users/{{user_name}}/.bundle/${bundle.name}/${bundle.target} permissions: diff --git a/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl b/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl index 57e56e2d27b..1bab573f2fa 100644 --- a/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl +++ b/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl @@ -5,7 +5,7 @@ fixed: type: databricks prompts: host: - default: {{.workspace.Hostname}} + default: {{(regexp "^https?://").ReplaceAllString workspace_host ""}} token: hint: 'personal access token to use, dapiXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' hide_input: true From 8e9774eb4d11fb6a43123bd971018102f844d4f7 Mon Sep 17 00:00:00 2001 From: "pavlo.kozlov" Date: Thu, 5 Nov 2026 09:26:28 +0000 Subject: [PATCH 07/10] Drop changes the built-in template migration doesn't need The host is no longer quoted. A URL with ?w= is a valid plain YAML value, and the quotes were only needed for test outputs, which no longer have ?w=. Welcome messages keep their "workspace_host:" label. The ?w= targets in strict_profile_match/host and the extra-workspace-input test are removed: the profiles test and the input tests in templates-machinery cover the same cases. Template outputs are now the same as before for auth without a workspace ID. Co-authored-by: Isaac --- .../strict_profile_match/host/databricks.yml | 6 ------ .../bundle/strict_profile_match/host/output.txt | 8 -------- .../bundle/strict_profile_match/host/script | 2 +- .../bundle/templates/dbt-sql-classic/output.txt | 2 +- acceptance/bundle/templates/dbt-sql/output.txt | 2 +- .../extra-workspace-input/input.json | 5 ----- .../extra-workspace-input/out.test.toml | 2 -- .../extra-workspace-input/output.txt | 17 ----------------- .../extra-workspace-input/script | 5 ----- .../default-minimal/profiles/output.txt | 8 ++++---- .../output/my_default_minimal/databricks.yml | 4 ++-- .../output/my_default_minimal/databricks.yml | 4 ++-- .../output/my_default_minimal/databricks.yml | 4 ++-- .../output/my_default_python/databricks.yml | 4 ++-- .../serverless-customcatalog/output.txt | 2 +- .../output/my_default_python/databricks.yml | 4 ++-- .../templates/default-scala-classic/output.txt | 2 +- .../bundle/templates/default-scala/output.txt | 2 +- .../output/my_default_scala/databricks.yml | 6 +++--- .../default-sql-catalog-dash/output.txt | 2 +- .../bundle/templates/default-sql/output.txt | 2 +- .../output/my_default_sql/databricks.yml | 4 ++-- .../out.default-python.databricks.yml | 4 ++-- .../templates/deployment-history/output.txt | 6 +++--- .../my_lakeflow_integrations/databricks.yml | 4 ++-- .../output/my_lakeflow_pipelines/databricks.yml | 4 ++-- .../output/my_lakeflow_pipelines/databricks.yml | 4 ++-- .../output/my_pydabs/databricks.yml | 4 ++-- .../templates/telemetry/dbt-sql/output.txt | 2 +- .../telemetry/default-python/out.databricks.yml | 4 ++-- .../telemetry/default-sql/out.databricks.yml | 4 ++-- .../templates/telemetry/default-sql/output.txt | 2 +- .../e2e/output/lakeflow_project/databricks.yml | 4 ++-- .../output/my_python_project/databricks.yml | 4 ++-- .../sql/output/my_sql_project/databricks.yml | 4 ++-- .../dbt-sql/databricks_template_schema.json | 2 +- .../databricks_template_schema.json | 2 +- .../{{.project_name}}/databricks.yml.tmpl | 6 +++--- .../default-sql/databricks_template_schema.json | 2 +- .../{{.project_name}}/databricks.yml.tmpl | 4 ++-- .../{{.project_name}}/databricks.yml.tmpl | 4 ++-- .../{{.project_name}}/databricks.yml.tmpl | 4 ++-- 42 files changed, 64 insertions(+), 107 deletions(-) delete mode 100644 acceptance/bundle/templates/default-minimal/extra-workspace-input/input.json delete mode 100644 acceptance/bundle/templates/default-minimal/extra-workspace-input/out.test.toml delete mode 100644 acceptance/bundle/templates/default-minimal/extra-workspace-input/output.txt delete mode 100644 acceptance/bundle/templates/default-minimal/extra-workspace-input/script diff --git a/acceptance/bundle/strict_profile_match/host/databricks.yml b/acceptance/bundle/strict_profile_match/host/databricks.yml index 55cbbe1aae8..5643f1b38c2 100644 --- a/acceptance/bundle/strict_profile_match/host/databricks.yml +++ b/acceptance/bundle/strict_profile_match/host/databricks.yml @@ -18,12 +18,6 @@ targets: custom_host: workspace: host: $CUSTOM_HOST/?o=$WORKSPACE_ID - classic_with_w: - workspace: - host: $CLASSIC_HOST?w=$WORKSPACE_ID - custom_host_with_w: - workspace: - host: $CUSTOM_HOST?w=$WORKSPACE_ID custom_host_workspace_id_field: workspace: host: $CUSTOM_HOST diff --git a/acceptance/bundle/strict_profile_match/host/output.txt b/acceptance/bundle/strict_profile_match/host/output.txt index 56cbb88faae..6c3dcbeefab 100644 --- a/acceptance/bundle/strict_profile_match/host/output.txt +++ b/acceptance/bundle/strict_profile_match/host/output.txt @@ -15,14 +15,6 @@ profile=workspace_custom_host host=[CUSTOM_HOST] workspace_id=[WORKSPACE_ID] >>> errcode [CLI] bundle run -t custom_host_workspace_id_field show_auth profile=workspace_custom_host host=[CUSTOM_HOST] workspace_id=[WORKSPACE_ID] -=== Target classic_with_w matches one profile ->>> errcode [CLI] bundle run -t classic_with_w show_auth -profile=workspace_classic_id host=[DATABRICKS_URL] workspace_id=[WORKSPACE_ID] - -=== Target custom_host_with_w matches one profile ->>> errcode [CLI] bundle run -t custom_host_with_w show_auth -profile=workspace_custom_host host=[CUSTOM_HOST] workspace_id=[WORKSPACE_ID] - === Target classic_other_workspace is rejected >>> errcode [CLI] bundle validate -t classic_other_workspace Error: cannot resolve bundle auth configuration: resolve: strict profile matching: no profile for host [DATABRICKS_URL] has workspace_id 2222222222. Config: host=[DATABRICKS_URL], workspace_id=2222222222, config_file=[TEST_TMP_DIR]/.databrickscfg, databricks_cli_path=[CLI]. Env: DATABRICKS_CONFIG_FILE, DATABRICKS_CLI_PATH diff --git a/acceptance/bundle/strict_profile_match/host/script b/acceptance/bundle/strict_profile_match/host/script index cac18599733..1a5e32067eb 100644 --- a/acceptance/bundle/strict_profile_match/host/script +++ b/acceptance/bundle/strict_profile_match/host/script @@ -1,4 +1,4 @@ -for target in classic classic_with_workspace_id custom_host custom_host_workspace_id_field classic_with_w custom_host_with_w; do +for target in classic classic_with_workspace_id custom_host custom_host_workspace_id_field; do title "Target $target matches one profile" trace errcode $CLI bundle run -t $target show_auth done diff --git a/acceptance/bundle/templates/dbt-sql-classic/output.txt b/acceptance/bundle/templates/dbt-sql-classic/output.txt index 9d9c3dd15e4..66c5cf492e0 100644 --- a/acceptance/bundle/templates/dbt-sql-classic/output.txt +++ b/acceptance/bundle/templates/dbt-sql-classic/output.txt @@ -4,7 +4,7 @@ Welcome to the dbt template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_url: [DATABRICKS_URL] +workspace_host: [DATABRICKS_URL] 📊 Your new project has been created in the 'my_dbt_sql' directory! If you already have dbt installed, just type 'cd my_dbt_sql; dbt init' to get started. diff --git a/acceptance/bundle/templates/dbt-sql/output.txt b/acceptance/bundle/templates/dbt-sql/output.txt index 340d69955a2..8555f15292c 100644 --- a/acceptance/bundle/templates/dbt-sql/output.txt +++ b/acceptance/bundle/templates/dbt-sql/output.txt @@ -4,7 +4,7 @@ Welcome to the dbt template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_url: [DATABRICKS_URL] +workspace_host: [DATABRICKS_URL] 📊 Your new project has been created in the 'my_dbt_sql' directory! If you already have dbt installed, just type 'cd my_dbt_sql; dbt init' to get started. diff --git a/acceptance/bundle/templates/default-minimal/extra-workspace-input/input.json b/acceptance/bundle/templates/default-minimal/extra-workspace-input/input.json deleted file mode 100644 index 0b2cdd03139..00000000000 --- a/acceptance/bundle/templates/default-minimal/extra-workspace-input/input.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "project_name": "my_default_minimal", - "language_choice": "python", - "workspace": "team-dev" -} diff --git a/acceptance/bundle/templates/default-minimal/extra-workspace-input/out.test.toml b/acceptance/bundle/templates/default-minimal/extra-workspace-input/out.test.toml deleted file mode 100644 index 19b5b15d11f..00000000000 --- a/acceptance/bundle/templates/default-minimal/extra-workspace-input/out.test.toml +++ /dev/null @@ -1,2 +0,0 @@ -Cloud = false -EnvMatrix.DMS = [""] diff --git a/acceptance/bundle/templates/default-minimal/extra-workspace-input/output.txt b/acceptance/bundle/templates/default-minimal/extra-workspace-input/output.txt deleted file mode 100644 index dc72ad846ae..00000000000 --- a/acceptance/bundle/templates/default-minimal/extra-workspace-input/output.txt +++ /dev/null @@ -1,17 +0,0 @@ - ->>> [CLI] bundle init default-minimal --config-file ./input.json -Welcome to the minimal Declarative Automation Bundle template! - -This template creates a minimal project structure without sample code, ideal for advanced users. -(For getting started with Python or SQL code, use the default-python or default-sql templates instead.) - -Your workspace at [DATABRICKS_URL] is used for initialization. -(See https://docs.databricks.com/dev-tools/cli/profiles.html for how to change your profile.) - -✨ Your new project has been created in the 'my_default_minimal' directory! - -To get started, refer to the project README.md file and the documentation at https://docs.databricks.com/dev-tools/bundles/index.html. - ->>> grep host: my_default_minimal/databricks.yml - host: "[DATABRICKS_URL]" - host: "[DATABRICKS_URL]" diff --git a/acceptance/bundle/templates/default-minimal/extra-workspace-input/script b/acceptance/bundle/templates/default-minimal/extra-workspace-input/script deleted file mode 100644 index e01fbd1a2f6..00000000000 --- a/acceptance/bundle/templates/default-minimal/extra-workspace-input/script +++ /dev/null @@ -1,5 +0,0 @@ -# The template doesn't declare a workspace input, so the extra key is ignored -# and the template still gets the workspace context. -trace $CLI bundle init default-minimal --config-file ./input.json -trace grep 'host:' my_default_minimal/databricks.yml -rm -r my_default_minimal diff --git a/acceptance/bundle/templates/default-minimal/profiles/output.txt b/acceptance/bundle/templates/default-minimal/profiles/output.txt index 3bbc918ef62..1c2849442ae 100644 --- a/acceptance/bundle/templates/default-minimal/profiles/output.txt +++ b/acceptance/bundle/templates/default-minimal/profiles/output.txt @@ -15,8 +15,8 @@ Your workspace at [DATABRICKS_URL] is used for initialization. To get started, refer to the project README.md file and the documentation at https://docs.databricks.com/dev-tools/bundles/index.html. >>> grep host: databricks.yml - host: "[DATABRICKS_URL]" - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] + host: [DATABRICKS_URL] >>> DATABRICKS_BUNDLE_STRICT_PROFILE_MATCH=1 [CLI] bundle validate -t dev Name: my_default_minimal @@ -49,8 +49,8 @@ Your workspace at [CUSTOM_HOST]?w=[WORKSPACE_ID] is used for initialization. To get started, refer to the project README.md file and the documentation at https://docs.databricks.com/dev-tools/bundles/index.html. >>> grep host: databricks.yml - host: "[CUSTOM_HOST]?w=[WORKSPACE_ID]" - host: "[CUSTOM_HOST]?w=[WORKSPACE_ID]" + host: [CUSTOM_HOST]?w=[WORKSPACE_ID] + host: [CUSTOM_HOST]?w=[WORKSPACE_ID] >>> DATABRICKS_BUNDLE_STRICT_PROFILE_MATCH=1 [CLI] bundle validate -t dev Name: my_default_minimal diff --git a/acceptance/bundle/templates/default-minimal/python/output/my_default_minimal/databricks.yml b/acceptance/bundle/templates/default-minimal/python/output/my_default_minimal/databricks.yml index 7a4c3fb8ba2..ec72bde8b31 100644 --- a/acceptance/bundle/templates/default-minimal/python/output/my_default_minimal/databricks.yml +++ b/acceptance/bundle/templates/default-minimal/python/output/my_default_minimal/databricks.yml @@ -23,14 +23,14 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: catalog: hive_metastore schema: ${workspace.current_user.short_name} prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/acceptance/bundle/templates/default-minimal/skip/output/my_default_minimal/databricks.yml b/acceptance/bundle/templates/default-minimal/skip/output/my_default_minimal/databricks.yml index 7a4c3fb8ba2..ec72bde8b31 100644 --- a/acceptance/bundle/templates/default-minimal/skip/output/my_default_minimal/databricks.yml +++ b/acceptance/bundle/templates/default-minimal/skip/output/my_default_minimal/databricks.yml @@ -23,14 +23,14 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: catalog: hive_metastore schema: ${workspace.current_user.short_name} prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/acceptance/bundle/templates/default-minimal/sql/output/my_default_minimal/databricks.yml b/acceptance/bundle/templates/default-minimal/sql/output/my_default_minimal/databricks.yml index 7a4c3fb8ba2..ec72bde8b31 100644 --- a/acceptance/bundle/templates/default-minimal/sql/output/my_default_minimal/databricks.yml +++ b/acceptance/bundle/templates/default-minimal/sql/output/my_default_minimal/databricks.yml @@ -23,14 +23,14 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: catalog: hive_metastore schema: ${workspace.current_user.short_name} prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/acceptance/bundle/templates/default-python/classic/output/my_default_python/databricks.yml b/acceptance/bundle/templates/default-python/classic/output/my_default_python/databricks.yml index 78dfa622a77..d5abd8c8fa4 100644 --- a/acceptance/bundle/templates/default-python/classic/output/my_default_python/databricks.yml +++ b/acceptance/bundle/templates/default-python/classic/output/my_default_python/databricks.yml @@ -28,7 +28,7 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: catalog: hive_metastore schema: ${workspace.current_user.short_name} @@ -37,7 +37,7 @@ targets: prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/acceptance/bundle/templates/default-python/serverless-customcatalog/output.txt b/acceptance/bundle/templates/default-python/serverless-customcatalog/output.txt index a33b555196a..3fe9b24b805 100644 --- a/acceptance/bundle/templates/default-python/serverless-customcatalog/output.txt +++ b/acceptance/bundle/templates/default-python/serverless-customcatalog/output.txt @@ -16,7 +16,7 @@ To get started, refer to the project README.md file and the documentation at htt --- [TESTROOT]/bundle/templates/default-python/serverless-customcatalog/../serverless/output/my_default_python/databricks.yml +++ output/my_default_python/databricks.yml @@ -31,5 +31,5 @@ - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: - catalog: hive_metastore + catalog: customcatalog diff --git a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/databricks.yml b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/databricks.yml index 25ecf7c58fc..b8ad3140314 100644 --- a/acceptance/bundle/templates/default-python/serverless/output/my_default_python/databricks.yml +++ b/acceptance/bundle/templates/default-python/serverless/output/my_default_python/databricks.yml @@ -28,14 +28,14 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: catalog: hive_metastore schema: ${workspace.current_user.short_name} prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/acceptance/bundle/templates/default-scala-classic/output.txt b/acceptance/bundle/templates/default-scala-classic/output.txt index f6649f78380..6ceb22ee71b 100644 --- a/acceptance/bundle/templates/default-scala-classic/output.txt +++ b/acceptance/bundle/templates/default-scala-classic/output.txt @@ -4,7 +4,7 @@ Welcome to the default-scala template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_url: [DATABRICKS_URL] +workspace_host: [DATABRICKS_URL] ✨ Your new project has been created in the 'my_default_scala' directory! diff --git a/acceptance/bundle/templates/default-scala/output.txt b/acceptance/bundle/templates/default-scala/output.txt index 3d43242bc4e..8a4f23f5a32 100644 --- a/acceptance/bundle/templates/default-scala/output.txt +++ b/acceptance/bundle/templates/default-scala/output.txt @@ -4,7 +4,7 @@ Welcome to the default-scala template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_url: [DATABRICKS_URL] +workspace_host: [DATABRICKS_URL] ✨ Your new project has been created in the 'my_default_scala' directory! diff --git a/acceptance/bundle/templates/default-scala/output/my_default_scala/databricks.yml b/acceptance/bundle/templates/default-scala/output/my_default_scala/databricks.yml index 4cde008ef58..9c979f25424 100644 --- a/acceptance/bundle/templates/default-scala/output/my_default_scala/databricks.yml +++ b/acceptance/bundle/templates/default-scala/output/my_default_scala/databricks.yml @@ -14,7 +14,7 @@ variables: description: The schema to use workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] artifact_path: /Volumes/test-folder/${bundle.name}/${bundle.target}/${workspace.current_user.short_name} artifacts: @@ -34,7 +34,7 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: catalog: main schema: ${workspace.current_user.short_name} @@ -42,7 +42,7 @@ targets: prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} permissions: diff --git a/acceptance/bundle/templates/default-sql-catalog-dash/output.txt b/acceptance/bundle/templates/default-sql-catalog-dash/output.txt index 85c1ebf6e27..23a18c5d02c 100644 --- a/acceptance/bundle/templates/default-sql-catalog-dash/output.txt +++ b/acceptance/bundle/templates/default-sql-catalog-dash/output.txt @@ -4,7 +4,7 @@ Welcome to the default SQL template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_url: [DATABRICKS_URL] +workspace_host: [DATABRICKS_URL] ✨ Your new project has been created in the 'my_default_sql' directory! diff --git a/acceptance/bundle/templates/default-sql/output.txt b/acceptance/bundle/templates/default-sql/output.txt index 6dde88fb158..222e5d7e1e6 100644 --- a/acceptance/bundle/templates/default-sql/output.txt +++ b/acceptance/bundle/templates/default-sql/output.txt @@ -4,7 +4,7 @@ Welcome to the default SQL template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_url: [DATABRICKS_URL] +workspace_host: [DATABRICKS_URL] ✨ Your new project has been created in the 'my_default_sql' directory! diff --git a/acceptance/bundle/templates/default-sql/output/my_default_sql/databricks.yml b/acceptance/bundle/templates/default-sql/output/my_default_sql/databricks.yml index d4fb2b9b9f4..965975a424a 100644 --- a/acceptance/bundle/templates/default-sql/output/my_default_sql/databricks.yml +++ b/acceptance/bundle/templates/default-sql/output/my_default_sql/databricks.yml @@ -25,7 +25,7 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: warehouse_id: f00dcafe catalog: main @@ -34,7 +34,7 @@ targets: prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/acceptance/bundle/templates/deployment-history/out.default-python.databricks.yml b/acceptance/bundle/templates/deployment-history/out.default-python.databricks.yml index b27b6fcd224..1de7c602976 100644 --- a/acceptance/bundle/templates/deployment-history/out.default-python.databricks.yml +++ b/acceptance/bundle/templates/deployment-history/out.default-python.databricks.yml @@ -31,14 +31,14 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: catalog: hive_metastore schema: ${workspace.current_user.short_name} prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/acceptance/bundle/templates/deployment-history/output.txt b/acceptance/bundle/templates/deployment-history/output.txt index c9f9febde46..a6f06bdcb77 100644 --- a/acceptance/bundle/templates/deployment-history/output.txt +++ b/acceptance/bundle/templates/deployment-history/output.txt @@ -17,7 +17,7 @@ experimental: Welcome to the default SQL template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_url: [DATABRICKS_URL] +workspace_host: [DATABRICKS_URL] ✨ Your new project has been created in the 'my_default_sql' directory! @@ -31,7 +31,7 @@ experimental: Welcome to the default-scala template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_url: [DATABRICKS_URL] +workspace_host: [DATABRICKS_URL] ✨ Your new project has been created in the 'my_default_scala' directory! @@ -45,7 +45,7 @@ experimental: Welcome to the dbt template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_url: [DATABRICKS_URL] +workspace_host: [DATABRICKS_URL] 📊 Your new project has been created in the 'my_dbt_sql' directory! If you already have dbt installed, just type 'cd my_dbt_sql; dbt init' to get started. diff --git a/acceptance/bundle/templates/lakeflow-integrations/output/my_lakeflow_integrations/databricks.yml b/acceptance/bundle/templates/lakeflow-integrations/output/my_lakeflow_integrations/databricks.yml index 92972c0592f..02aa0c5ad78 100644 --- a/acceptance/bundle/templates/lakeflow-integrations/output/my_lakeflow_integrations/databricks.yml +++ b/acceptance/bundle/templates/lakeflow-integrations/output/my_lakeflow_integrations/databricks.yml @@ -37,11 +37,11 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} permissions: diff --git a/acceptance/bundle/templates/lakeflow-pipelines/python/output/my_lakeflow_pipelines/databricks.yml b/acceptance/bundle/templates/lakeflow-pipelines/python/output/my_lakeflow_pipelines/databricks.yml index 998fa4f2f5f..a86e4e792a1 100644 --- a/acceptance/bundle/templates/lakeflow-pipelines/python/output/my_lakeflow_pipelines/databricks.yml +++ b/acceptance/bundle/templates/lakeflow-pipelines/python/output/my_lakeflow_pipelines/databricks.yml @@ -23,14 +23,14 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: catalog: main schema: ${workspace.current_user.short_name} prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/acceptance/bundle/templates/lakeflow-pipelines/sql/output/my_lakeflow_pipelines/databricks.yml b/acceptance/bundle/templates/lakeflow-pipelines/sql/output/my_lakeflow_pipelines/databricks.yml index 998fa4f2f5f..a86e4e792a1 100644 --- a/acceptance/bundle/templates/lakeflow-pipelines/sql/output/my_lakeflow_pipelines/databricks.yml +++ b/acceptance/bundle/templates/lakeflow-pipelines/sql/output/my_lakeflow_pipelines/databricks.yml @@ -23,14 +23,14 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: catalog: main schema: ${workspace.current_user.short_name} prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/acceptance/bundle/templates/pydabs/init-classic/output/my_pydabs/databricks.yml b/acceptance/bundle/templates/pydabs/init-classic/output/my_pydabs/databricks.yml index 7de11c34913..299ee6fd9ac 100644 --- a/acceptance/bundle/templates/pydabs/init-classic/output/my_pydabs/databricks.yml +++ b/acceptance/bundle/templates/pydabs/init-classic/output/my_pydabs/databricks.yml @@ -34,7 +34,7 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: catalog: hive_metastore schema: ${workspace.current_user.short_name} @@ -43,7 +43,7 @@ targets: prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/acceptance/bundle/templates/telemetry/dbt-sql/output.txt b/acceptance/bundle/templates/telemetry/dbt-sql/output.txt index 606fd91719e..74e0bac9312 100644 --- a/acceptance/bundle/templates/telemetry/dbt-sql/output.txt +++ b/acceptance/bundle/templates/telemetry/dbt-sql/output.txt @@ -2,7 +2,7 @@ Welcome to the dbt template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_url: [DATABRICKS_URL] +workspace_host: [DATABRICKS_URL] 📊 Your new project has been created in the 'my_dbt_sql' directory! If you already have dbt installed, just type 'cd my_dbt_sql; dbt init' to get started. diff --git a/acceptance/bundle/templates/telemetry/default-python/out.databricks.yml b/acceptance/bundle/templates/telemetry/default-python/out.databricks.yml index 9124e938957..964e6e704f4 100644 --- a/acceptance/bundle/templates/telemetry/default-python/out.databricks.yml +++ b/acceptance/bundle/templates/telemetry/default-python/out.databricks.yml @@ -28,7 +28,7 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: catalog: hive_metastore schema: ${workspace.current_user.short_name} @@ -37,7 +37,7 @@ targets: prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/acceptance/bundle/templates/telemetry/default-sql/out.databricks.yml b/acceptance/bundle/templates/telemetry/default-sql/out.databricks.yml index a8d6191d630..bdc9573808d 100644 --- a/acceptance/bundle/templates/telemetry/default-sql/out.databricks.yml +++ b/acceptance/bundle/templates/telemetry/default-sql/out.databricks.yml @@ -25,7 +25,7 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: warehouse_id: f00dcafe catalog: main @@ -34,7 +34,7 @@ targets: prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/acceptance/bundle/templates/telemetry/default-sql/output.txt b/acceptance/bundle/templates/telemetry/default-sql/output.txt index 67ebb78d0e9..775d86933af 100644 --- a/acceptance/bundle/templates/telemetry/default-sql/output.txt +++ b/acceptance/bundle/templates/telemetry/default-sql/output.txt @@ -2,7 +2,7 @@ Welcome to the default SQL template for Declarative Automation Bundles! A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. -workspace_url: [DATABRICKS_URL] +workspace_host: [DATABRICKS_URL] ✨ Your new project has been created in the 'my_default_sql' directory! diff --git a/acceptance/pipelines/e2e/output/lakeflow_project/databricks.yml b/acceptance/pipelines/e2e/output/lakeflow_project/databricks.yml index fe9666ebe34..67f65788f23 100644 --- a/acceptance/pipelines/e2e/output/lakeflow_project/databricks.yml +++ b/acceptance/pipelines/e2e/output/lakeflow_project/databricks.yml @@ -23,14 +23,14 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: catalog: hive_metastore schema: ${workspace.current_user.short_name} prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/acceptance/pipelines/init/python/output/my_python_project/databricks.yml b/acceptance/pipelines/init/python/output/my_python_project/databricks.yml index 2fceec998e7..6fee1dfff76 100644 --- a/acceptance/pipelines/init/python/output/my_python_project/databricks.yml +++ b/acceptance/pipelines/init/python/output/my_python_project/databricks.yml @@ -23,14 +23,14 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: catalog: main schema: ${workspace.current_user.short_name} prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/acceptance/pipelines/init/sql/output/my_sql_project/databricks.yml b/acceptance/pipelines/init/sql/output/my_sql_project/databricks.yml index b7d2d716e29..60823122702 100644 --- a/acceptance/pipelines/init/sql/output/my_sql_project/databricks.yml +++ b/acceptance/pipelines/init/sql/output/my_sql_project/databricks.yml @@ -23,14 +23,14 @@ targets: mode: development default: true workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] variables: catalog: main schema: ${workspace.current_user.short_name} prod: mode: production workspace: - host: "[DATABRICKS_URL]" + host: [DATABRICKS_URL] # We explicitly deploy to /Workspace/Users/[USERNAME] to make sure we only have a single copy. root_path: /Workspace/Users/[USERNAME]/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/libs/template/templates/dbt-sql/databricks_template_schema.json b/libs/template/templates/dbt-sql/databricks_template_schema.json index 15cae9ae393..7e6c0b93952 100644 --- a/libs/template/templates/dbt-sql/databricks_template_schema.json +++ b/libs/template/templates/dbt-sql/databricks_template_schema.json @@ -1,5 +1,5 @@ { - "welcome_message": "\nWelcome to the dbt template for Declarative Automation Bundles!\n\nA workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html.\nworkspace_url: {{.workspace.URL}}", + "welcome_message": "\nWelcome to the dbt template for Declarative Automation Bundles!\n\nA workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html.\nworkspace_host: {{.workspace.URL}}", "properties": { "project_name": { "type": "string", diff --git a/libs/template/templates/default-scala/databricks_template_schema.json b/libs/template/templates/default-scala/databricks_template_schema.json index 2a9e5cc72a4..652c0d374e4 100644 --- a/libs/template/templates/default-scala/databricks_template_schema.json +++ b/libs/template/templates/default-scala/databricks_template_schema.json @@ -1,5 +1,5 @@ { - "welcome_message": "\nWelcome to the default-scala template for Declarative Automation Bundles!\n\nA workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html.\nworkspace_url: {{.workspace.URL}}", + "welcome_message": "\nWelcome to the default-scala template for Declarative Automation Bundles!\n\nA workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html.\nworkspace_host: {{.workspace.URL}}", "properties": { "project_name": { "type": "string", diff --git a/libs/template/templates/default-scala/template/{{.project_name}}/databricks.yml.tmpl b/libs/template/templates/default-scala/template/{{.project_name}}/databricks.yml.tmpl index 1351441e11b..ec11354f3b6 100644 --- a/libs/template/templates/default-scala/template/{{.project_name}}/databricks.yml.tmpl +++ b/libs/template/templates/default-scala/template/{{.project_name}}/databricks.yml.tmpl @@ -22,7 +22,7 @@ variables: {{- end}} workspace: - host: "{{.workspace.URL}}" + host: {{.workspace.URL}} artifact_path: {{.artifacts_dest_path}}/${bundle.name}/${bundle.target}/${workspace.current_user.short_name} artifacts: @@ -42,7 +42,7 @@ targets: mode: development default: true workspace: - host: "{{.workspace.URL}}" + host: {{.workspace.URL}} variables: catalog: {{.default_catalog}} schema: {{$dev_schema}} @@ -50,7 +50,7 @@ targets: prod: mode: production workspace: - host: "{{.workspace.URL}}" + host: {{.workspace.URL}} # We explicitly deploy to /Workspace/Users/{{user_name}} to make sure we only have a single copy. root_path: /Workspace/Users/{{user_name}}/.bundle/${bundle.name}/${bundle.target} permissions: diff --git a/libs/template/templates/default-sql/databricks_template_schema.json b/libs/template/templates/default-sql/databricks_template_schema.json index 2fc7e31ec15..6967c3ec123 100644 --- a/libs/template/templates/default-sql/databricks_template_schema.json +++ b/libs/template/templates/default-sql/databricks_template_schema.json @@ -1,5 +1,5 @@ { - "welcome_message": "\nWelcome to the default SQL template for Declarative Automation Bundles!\n\nA workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html.\nworkspace_url: {{.workspace.URL}}", + "welcome_message": "\nWelcome to the default SQL template for Declarative Automation Bundles!\n\nA workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html.\nworkspace_host: {{.workspace.URL}}", "properties": { "project_name": { "type": "string", diff --git a/libs/template/templates/default-sql/template/{{.project_name}}/databricks.yml.tmpl b/libs/template/templates/default-sql/template/{{.project_name}}/databricks.yml.tmpl index c57b8594f26..cfc2c2cc2fc 100644 --- a/libs/template/templates/default-sql/template/{{.project_name}}/databricks.yml.tmpl +++ b/libs/template/templates/default-sql/template/{{.project_name}}/databricks.yml.tmpl @@ -33,7 +33,7 @@ targets: mode: development default: true workspace: - host: "{{.workspace.URL}}" + host: {{.workspace.URL}} variables: warehouse_id: {{index ((regexp "[^/]+$").FindStringSubmatch .http_path) 0}} catalog: {{.default_catalog}} @@ -42,7 +42,7 @@ targets: prod: mode: production workspace: - host: "{{.workspace.URL}}" + host: {{.workspace.URL}} # We explicitly deploy to /Workspace/Users/{{user_name}} to make sure we only have a single copy. root_path: /Workspace/Users/{{user_name}}/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/libs/template/templates/default/template/{{.project_name}}/databricks.yml.tmpl b/libs/template/templates/default/template/{{.project_name}}/databricks.yml.tmpl index 1ea3bf752d2..42b15164c8e 100644 --- a/libs/template/templates/default/template/{{.project_name}}/databricks.yml.tmpl +++ b/libs/template/templates/default/template/{{.project_name}}/databricks.yml.tmpl @@ -49,7 +49,7 @@ targets: mode: development default: true workspace: - host: "{{.workspace.URL}}" + host: {{.workspace.URL}} variables: catalog: {{.default_catalog}} schema: {{$dev_schema}} @@ -60,7 +60,7 @@ targets: prod: mode: production workspace: - host: "{{.workspace.URL}}" + host: {{.workspace.URL}} # We explicitly deploy to /Workspace/Users/{{user_name}} to make sure we only have a single copy. root_path: /Workspace/Users/{{user_name}}/.bundle/${bundle.name}/${bundle.target} variables: diff --git a/libs/template/templates/lakeflow-integrations/template/{{.project_name}}/databricks.yml.tmpl b/libs/template/templates/lakeflow-integrations/template/{{.project_name}}/databricks.yml.tmpl index cf75bae798f..ba651def676 100644 --- a/libs/template/templates/lakeflow-integrations/template/{{.project_name}}/databricks.yml.tmpl +++ b/libs/template/templates/lakeflow-integrations/template/{{.project_name}}/databricks.yml.tmpl @@ -38,11 +38,11 @@ targets: mode: development default: true workspace: - host: "{{.workspace.URL}}" + host: {{.workspace.URL}} prod: mode: production workspace: - host: "{{.workspace.URL}}" + host: {{.workspace.URL}} # We explicitly deploy to /Workspace/Users/{{user_name}} to make sure we only have a single copy. root_path: /Workspace/Users/{{user_name}}/.bundle/${bundle.name}/${bundle.target} permissions: From 67b856dcbd993729f98b7581ed1a858cc0101389 Mon Sep 17 00:00:00 2001 From: "pavlo.kozlov" Date: Thu, 5 Nov 2026 12:19:33 +0000 Subject: [PATCH 08/10] Use .workspace in the dbt-sql template The bundle host comes from .workspace.URL like in the other built-in templates. Deployed dbt jobs get their host from Databricks, so they don't read it. The HTTP path suggested for dbt init gets ?o= when the workspace URL has the ID, because dbt selects the workspace on a host shared by several workspaces with ?o= in the HTTP path. The host suggested for dbt init is .workspace.Hostname. Co-authored-by: Isaac --- .../builtin-templates-workspace-url.md | 2 +- .../templates/dbt-sql-workspace-id/input.json | 6 ++++ .../dbt-sql-workspace-id/out.test.toml | 2 ++ .../templates/dbt-sql-workspace-id/output.txt | 24 +++++++++++++++ .../templates/dbt-sql-workspace-id/script | 29 +++++++++++++++++++ .../templates/dbt-sql-workspace-id/test.toml | 1 + .../output/my_dbt_sql/profile_template.yml | 2 +- .../{{.project_name}}/databricks.yml.tmpl | 4 +-- .../profile_template.yml.tmpl | 7 +++-- 9 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 acceptance/bundle/templates/dbt-sql-workspace-id/input.json create mode 100644 acceptance/bundle/templates/dbt-sql-workspace-id/out.test.toml create mode 100644 acceptance/bundle/templates/dbt-sql-workspace-id/output.txt create mode 100644 acceptance/bundle/templates/dbt-sql-workspace-id/script create mode 100644 acceptance/bundle/templates/dbt-sql-workspace-id/test.toml diff --git a/.nextchanges/bundles/builtin-templates-workspace-url.md b/.nextchanges/bundles/builtin-templates-workspace-url.md index cb97fad3984..76e97992a1e 100644 --- a/.nextchanges/bundles/builtin-templates-workspace-url.md +++ b/.nextchanges/bundles/builtin-templates-workspace-url.md @@ -1 +1 @@ -* Built-in templates (except `dbt-sql`) add the workspace ID to `workspace.host` (`?w=`) when the profile or an environment variable sets it, so generated bundles select the right workspace on hosts shared by several workspaces. Welcome messages of all built-in templates show the workspace URL. ([#7350](https://github.com/databricks/cli/pull/7350)) +* Built-in templates add the workspace ID to `workspace.host` (`?w=`) when the profile or an environment variable sets it, so generated bundles select the right workspace on hosts shared by several workspaces. Welcome messages show the same URL, and `dbt-sql` also adds `?o=` to the HTTP path it suggests for `dbt init`. ([#7350](https://github.com/databricks/cli/pull/7350)) diff --git a/acceptance/bundle/templates/dbt-sql-workspace-id/input.json b/acceptance/bundle/templates/dbt-sql-workspace-id/input.json new file mode 100644 index 00000000000..ca84320e6d7 --- /dev/null +++ b/acceptance/bundle/templates/dbt-sql-workspace-id/input.json @@ -0,0 +1,6 @@ +{ + "project_name": "my_dbt_sql", + "http_path": "/sql/2.0/warehouses/f00dcafe", + "default_catalog": "main", + "personal_schemas": "yes" +} diff --git a/acceptance/bundle/templates/dbt-sql-workspace-id/out.test.toml b/acceptance/bundle/templates/dbt-sql-workspace-id/out.test.toml new file mode 100644 index 00000000000..19b5b15d11f --- /dev/null +++ b/acceptance/bundle/templates/dbt-sql-workspace-id/out.test.toml @@ -0,0 +1,2 @@ +Cloud = false +EnvMatrix.DMS = [""] diff --git a/acceptance/bundle/templates/dbt-sql-workspace-id/output.txt b/acceptance/bundle/templates/dbt-sql-workspace-id/output.txt new file mode 100644 index 00000000000..9a9b24857de --- /dev/null +++ b/acceptance/bundle/templates/dbt-sql-workspace-id/output.txt @@ -0,0 +1,24 @@ + +=== Profile no_workspace_id + +>>> grep host: my_dbt_sql/databricks.yml + host: [DATABRICKS_URL] + host: [DATABRICKS_URL] + +>>> grep -E ^ default: [^{] my_dbt_sql/profile_template.yml + default: 127.0.0.1 + default: /sql/2.0/warehouses/f00dcafe + default: main + default: 4 + +=== Profile custom_host + +>>> grep host: my_dbt_sql/databricks.yml + host: [CUSTOM_HOST]?w=[WORKSPACE_ID] + host: [CUSTOM_HOST]?w=[WORKSPACE_ID] + +>>> grep -E ^ default: [^{] my_dbt_sql/profile_template.yml + default: localhost + default: /sql/2.0/warehouses/f00dcafe?o=[WORKSPACE_ID] + default: main + default: 4 diff --git a/acceptance/bundle/templates/dbt-sql-workspace-id/script b/acceptance/bundle/templates/dbt-sql-workspace-id/script new file mode 100644 index 00000000000..2de3af654fd --- /dev/null +++ b/acceptance/bundle/templates/dbt-sql-workspace-id/script @@ -0,0 +1,29 @@ +# The test server is reachable as both 127.0.0.1 and localhost. The second +# stands in for a host shared by several workspaces. +CUSTOM_HOST=${DATABRICKS_HOST/127.0.0.1/localhost} +add_repl "$CUSTOM_HOST" CUSTOM_HOST +WORKSPACE_ID=$(curl -s "$DATABRICKS_HOST/.well-known/databricks-config" | jq -r .workspace_id) + +cat > .databrickscfg < /dev/null 2>&1 + trace grep 'host:' my_dbt_sql/databricks.yml + trace grep -E "^ default: [^{]" my_dbt_sql/profile_template.yml + rm -r my_dbt_sql +done diff --git a/acceptance/bundle/templates/dbt-sql-workspace-id/test.toml b/acceptance/bundle/templates/dbt-sql-workspace-id/test.toml new file mode 100644 index 00000000000..7b3e1dcab84 --- /dev/null +++ b/acceptance/bundle/templates/dbt-sql-workspace-id/test.toml @@ -0,0 +1 @@ +Ignore = [".databrickscfg"] diff --git a/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/profile_template.yml b/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/profile_template.yml index bdb41ab202e..49b872b6d55 100644 --- a/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/profile_template.yml +++ b/acceptance/bundle/templates/dbt-sql/output/my_dbt_sql/profile_template.yml @@ -5,7 +5,7 @@ fixed: type: databricks prompts: host: - default: [DATABRICKS_HOST] + default: 127.0.0.1 token: hint: 'personal access token to use, dapiXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' hide_input: true diff --git a/libs/template/templates/dbt-sql/template/{{.project_name}}/databricks.yml.tmpl b/libs/template/templates/dbt-sql/template/{{.project_name}}/databricks.yml.tmpl index 21c82234a83..0f6ea969c30 100644 --- a/libs/template/templates/dbt-sql/template/{{.project_name}}/databricks.yml.tmpl +++ b/libs/template/templates/dbt-sql/template/{{.project_name}}/databricks.yml.tmpl @@ -20,12 +20,12 @@ targets: mode: development default: true workspace: - host: {{workspace_host}} + host: {{.workspace.URL}} prod: mode: production workspace: - host: {{workspace_host}} + host: {{.workspace.URL}} # We explicitly deploy to /Workspace/Users/{{user_name}} to make sure we only have a single copy. root_path: /Workspace/Users/{{user_name}}/.bundle/${bundle.name}/${bundle.target} permissions: diff --git a/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl b/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl index 1bab573f2fa..a591e8ae495 100644 --- a/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl +++ b/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl @@ -5,13 +5,16 @@ fixed: type: databricks prompts: host: - default: {{(regexp "^https?://").ReplaceAllString workspace_host ""}} + default: {{.workspace.Hostname}} token: hint: 'personal access token to use, dapiXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' hide_input: true http_path: hint: 'HTTP path of SQL warehouse to use' - default: {{.http_path}} + {{- /* dbt selects the workspace on a host shared by several workspaces with ?o= in the + HTTP path. Use the ID from the workspace URL, which has it when the profile sets it. */}} + {{- $id := (regexp `[?&]w=([^&#]+)`).FindStringSubmatch .workspace.URL}} + default: {{.http_path}}{{if $id}}?o={{index $id 1}}{{end}} {{- if eq .default_catalog ""}} _choose_unity_catalog: 'use the default workspace catalog (or do not use Unity Catalog)': From c19f462de25e7f9de130e8b6bca19039b531242a Mon Sep 17 00:00:00 2001 From: "pavlo.kozlov" Date: Thu, 5 Nov 2026 13:55:10 +0000 Subject: [PATCH 09/10] Update outputs for .workspace.Hostname with the port The dbt-sql profile default for dbt init is host:port again, so its output is the same as before. Co-authored-by: Isaac --- acceptance/bundle/templates/dbt-sql-workspace-id/output.txt | 4 ++-- acceptance/bundle/templates/dbt-sql-workspace-id/script | 1 + .../templates/dbt-sql/output/my_dbt_sql/profile_template.yml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/acceptance/bundle/templates/dbt-sql-workspace-id/output.txt b/acceptance/bundle/templates/dbt-sql-workspace-id/output.txt index 9a9b24857de..a65193b343f 100644 --- a/acceptance/bundle/templates/dbt-sql-workspace-id/output.txt +++ b/acceptance/bundle/templates/dbt-sql-workspace-id/output.txt @@ -6,7 +6,7 @@ host: [DATABRICKS_URL] >>> grep -E ^ default: [^{] my_dbt_sql/profile_template.yml - default: 127.0.0.1 + default: [DATABRICKS_HOST] default: /sql/2.0/warehouses/f00dcafe default: main default: 4 @@ -18,7 +18,7 @@ host: [CUSTOM_HOST]?w=[WORKSPACE_ID] >>> grep -E ^ default: [^{] my_dbt_sql/profile_template.yml - default: localhost + default: [CUSTOM_HOSTNAME] default: /sql/2.0/warehouses/f00dcafe?o=[WORKSPACE_ID] default: main default: 4 diff --git a/acceptance/bundle/templates/dbt-sql-workspace-id/script b/acceptance/bundle/templates/dbt-sql-workspace-id/script index 2de3af654fd..adc37b81794 100644 --- a/acceptance/bundle/templates/dbt-sql-workspace-id/script +++ b/acceptance/bundle/templates/dbt-sql-workspace-id/script @@ -2,6 +2,7 @@ # stands in for a host shared by several workspaces. CUSTOM_HOST=${DATABRICKS_HOST/127.0.0.1/localhost} add_repl "$CUSTOM_HOST" CUSTOM_HOST +add_repl "${CUSTOM_HOST#*://}" CUSTOM_HOSTNAME WORKSPACE_ID=$(curl -s "$DATABRICKS_HOST/.well-known/databricks-config" | jq -r .workspace_id) cat > .databrickscfg < Date: Fri, 6 Nov 2026 14:04:12 +0000 Subject: [PATCH 10/10] Use .workspace.URLID and setup_custom_host in built-in template tests dbt-sql adds ?o= from .workspace.URLID, escaped, instead of parsing the rendered URL with a regex. The profiles and dbt-sql-workspace-id tests use setup_custom_host instead of their own copy of that setup, and the dbt-sql-workspace-id test traces bundle init so a failed init shows its error. Co-authored-by: Isaac --- .../templates/dbt-sql-workspace-id/output.txt | 24 +++++++++++++++++++ .../templates/dbt-sql-workspace-id/script | 9 ++----- .../templates/default-minimal/profiles/script | 6 +---- .../default-minimal/profiles/test.toml | 2 +- .../profile_template.yml.tmpl | 5 ++-- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/acceptance/bundle/templates/dbt-sql-workspace-id/output.txt b/acceptance/bundle/templates/dbt-sql-workspace-id/output.txt index a65193b343f..836fba4f276 100644 --- a/acceptance/bundle/templates/dbt-sql-workspace-id/output.txt +++ b/acceptance/bundle/templates/dbt-sql-workspace-id/output.txt @@ -1,6 +1,18 @@ === Profile no_workspace_id +>>> [CLI] bundle init dbt-sql --config-file ./input.json --profile no_workspace_id + +Welcome to the dbt template for Declarative Automation Bundles! + +A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. +workspace_host: [DATABRICKS_URL] + +📊 Your new project has been created in the 'my_dbt_sql' directory! +If you already have dbt installed, just type 'cd my_dbt_sql; dbt init' to get started. +Refer to the README.md file for full "getting started" guide and production setup instructions. + + >>> grep host: my_dbt_sql/databricks.yml host: [DATABRICKS_URL] host: [DATABRICKS_URL] @@ -13,6 +25,18 @@ === Profile custom_host +>>> [CLI] bundle init dbt-sql --config-file ./input.json --profile custom_host + +Welcome to the dbt template for Declarative Automation Bundles! + +A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html. +workspace_host: [CUSTOM_HOST]?w=[WORKSPACE_ID] + +📊 Your new project has been created in the 'my_dbt_sql' directory! +If you already have dbt installed, just type 'cd my_dbt_sql; dbt init' to get started. +Refer to the README.md file for full "getting started" guide and production setup instructions. + + >>> grep host: my_dbt_sql/databricks.yml host: [CUSTOM_HOST]?w=[WORKSPACE_ID] host: [CUSTOM_HOST]?w=[WORKSPACE_ID] diff --git a/acceptance/bundle/templates/dbt-sql-workspace-id/script b/acceptance/bundle/templates/dbt-sql-workspace-id/script index adc37b81794..f7cfa1bd350 100644 --- a/acceptance/bundle/templates/dbt-sql-workspace-id/script +++ b/acceptance/bundle/templates/dbt-sql-workspace-id/script @@ -1,9 +1,4 @@ -# The test server is reachable as both 127.0.0.1 and localhost. The second -# stands in for a host shared by several workspaces. -CUSTOM_HOST=${DATABRICKS_HOST/127.0.0.1/localhost} -add_repl "$CUSTOM_HOST" CUSTOM_HOST -add_repl "${CUSTOM_HOST#*://}" CUSTOM_HOSTNAME -WORKSPACE_ID=$(curl -s "$DATABRICKS_HOST/.well-known/databricks-config" | jq -r .workspace_id) +setup_custom_host cat > .databrickscfg < /dev/null 2>&1 + trace $CLI bundle init dbt-sql --config-file ./input.json --profile $profile trace grep 'host:' my_dbt_sql/databricks.yml trace grep -E "^ default: [^{]" my_dbt_sql/profile_template.yml rm -r my_dbt_sql diff --git a/acceptance/bundle/templates/default-minimal/profiles/script b/acceptance/bundle/templates/default-minimal/profiles/script index 00a3795fdaf..f3d1d94a153 100644 --- a/acceptance/bundle/templates/default-minimal/profiles/script +++ b/acceptance/bundle/templates/default-minimal/profiles/script @@ -1,8 +1,4 @@ -# The test server is reachable as both 127.0.0.1 and localhost. The second -# stands in for a host shared by several workspaces. -CUSTOM_HOST=${DATABRICKS_HOST/127.0.0.1/localhost} -add_repl "$CUSTOM_HOST" CUSTOM_HOST -WORKSPACE_ID=$(curl -s "$DATABRICKS_HOST/.well-known/databricks-config" | jq -r .workspace_id) +setup_custom_host # The classic profile has no workspace_id. The SDK resolves the ID from host # metadata, but the generated host stays without ?w= so that it matches the diff --git a/acceptance/bundle/templates/default-minimal/profiles/test.toml b/acceptance/bundle/templates/default-minimal/profiles/test.toml index 75cb7d8de44..c6eb8cb8eb3 100644 --- a/acceptance/bundle/templates/default-minimal/profiles/test.toml +++ b/acceptance/bundle/templates/default-minimal/profiles/test.toml @@ -1,2 +1,2 @@ -# Written by script. +# The script writes .databrickscfg. Ignore = [".databrickscfg"] diff --git a/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl b/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl index a591e8ae495..279b5bf63b6 100644 --- a/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl +++ b/libs/template/templates/dbt-sql/template/{{.project_name}}/profile_template.yml.tmpl @@ -12,9 +12,8 @@ prompts: http_path: hint: 'HTTP path of SQL warehouse to use' {{- /* dbt selects the workspace on a host shared by several workspaces with ?o= in the - HTTP path. Use the ID from the workspace URL, which has it when the profile sets it. */}} - {{- $id := (regexp `[?&]w=([^&#]+)`).FindStringSubmatch .workspace.URL}} - default: {{.http_path}}{{if $id}}?o={{index $id 1}}{{end}} + HTTP path. Add it when the workspace URL has the ID. */}} + default: {{.http_path}}{{with .workspace.URLID}}?o={{urlquery .}}{{end}} {{- if eq .default_catalog ""}} _choose_unity_catalog: 'use the default workspace catalog (or do not use Unity Catalog)':