From 88568bfe224fac9758958c902d1da0bfb3b7a01a Mon Sep 17 00:00:00 2001 From: Jan Rose Date: Fri, 10 Jul 2026 09:36:37 +0200 Subject: [PATCH 1/4] Recognize ssh:// template URLs in bundle init gitUrlPrefixes was incomplete relative to the git URL spec (https://git-scm.com/docs/git-clone#_git_urls). Add ssh:// so that `databricks bundle init` clones from SSH-transport URLs. Also rename IsRepoUrl to IsGitRepoUrl and simplify it to return directly on match. Fixes #5881 Co-authored-by: Isaac --- NEXT_CHANGELOG.md | 1 + libs/template/resolver.go | 14 ++++++++------ libs/template/resolver_test.go | 21 +++++++++++++++------ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 0f71834ff56..f6588289dac 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -5,6 +5,7 @@ ### Notable Changes ### CLI +* Recognize `ssh://` template URLs in `databricks bundle init` ([#5881](https://github.com/databricks/cli/issues/5881)). ### Bundles diff --git a/libs/template/resolver.go b/libs/template/resolver.go index b5a2fa8d881..f7ca1f9c829 100644 --- a/libs/template/resolver.go +++ b/libs/template/resolver.go @@ -8,20 +8,22 @@ import ( "github.com/databricks/cli/libs/git" ) +// See https://git-scm.com/docs/git-clone#_git_urls for the set of supported +// Git URL forms. We deliberately exclude deprecated/insecure protocols (git, http, ftp[s]). var gitUrlPrefixes = []string{ "https://", + "ssh://", + // recognize git@ without ssh:// protocol because this is very common "git@", } -func IsRepoUrl(url string) bool { - result := false +func IsGitRepoUrl(url string) bool { for _, prefix := range gitUrlPrefixes { if strings.HasPrefix(url, prefix) { - result = true - break + return true } } - return result + return false } // ResolveReader resolves a template path/URL to a Reader (built-in, git or local) @@ -30,7 +32,7 @@ func ResolveReader(templatePathOrUrl, templateDir, ref string) (Reader, bool) { return tmpl.Reader, false } - if IsRepoUrl(templatePathOrUrl) { + if IsGitRepoUrl(templatePathOrUrl) { return NewGitReader(templatePathOrUrl, ref, templateDir, git.Clone), true } diff --git a/libs/template/resolver_test.go b/libs/template/resolver_test.go index 2174fe1afe9..c72079b267b 100644 --- a/libs/template/resolver_test.go +++ b/libs/template/resolver_test.go @@ -100,12 +100,21 @@ func TestTemplateResolverForCustomPath(t *testing.T) { assert.Equal(t, "/config/file", tmpl.Writer.(*defaultWriter).configPath) } -func TestBundleInitIsRepoUrl(t *testing.T) { - assert.True(t, IsRepoUrl("git@github.com:databricks/cli.git")) - assert.True(t, IsRepoUrl("https://github.com/databricks/cli.git")) - - assert.False(t, IsRepoUrl("./local")) - assert.False(t, IsRepoUrl("foo")) +func TestBundleInitIsGitRepoUrl(t *testing.T) { + // Supported + assert.True(t, IsGitRepoUrl("git@github.com:databricks/cli.git")) + assert.True(t, IsGitRepoUrl("https://github.com/databricks/cli.git")) + assert.True(t, IsGitRepoUrl("ssh://git@github.com/databricks/cli.git")) + + // Unsupported + assert.False(t, IsGitRepoUrl("git://github.com/databricks/cli.git")) + assert.False(t, IsGitRepoUrl("http://github.com/databricks/cli.git")) + assert.False(t, IsGitRepoUrl("ftp://github.com/databricks/cli.git")) + assert.False(t, IsGitRepoUrl("ftps://github.com/databricks/cli.git")) + + // Not git repos + assert.False(t, IsGitRepoUrl("./local")) + assert.False(t, IsGitRepoUrl("foo")) } func TestResolveReader(t *testing.T) { From 885abe9fa88853b5ea79a22750538b59ae98f482 Mon Sep 17 00:00:00 2001 From: Jan Rose Date: Fri, 10 Jul 2026 09:37:30 +0200 Subject: [PATCH 2/4] Reference PR instead of issue in changelog entry Co-authored-by: Isaac --- NEXT_CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index f6588289dac..bd2aee56c46 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -5,7 +5,7 @@ ### Notable Changes ### CLI -* Recognize `ssh://` template URLs in `databricks bundle init` ([#5881](https://github.com/databricks/cli/issues/5881)). +* Recognize `ssh://` template URLs in `databricks bundle init` ([#5891](https://github.com/databricks/cli/pull/5891)). ### Bundles From da6bdb9535543b3b62150989b4aaaa25c0a61d40 Mon Sep 17 00:00:00 2001 From: Jan Rose Date: Fri, 10 Jul 2026 09:42:49 +0200 Subject: [PATCH 3/4] Add test case for bare host path without scheme Co-authored-by: Isaac --- libs/template/resolver_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/template/resolver_test.go b/libs/template/resolver_test.go index c72079b267b..df3e3768525 100644 --- a/libs/template/resolver_test.go +++ b/libs/template/resolver_test.go @@ -115,6 +115,7 @@ func TestBundleInitIsGitRepoUrl(t *testing.T) { // Not git repos assert.False(t, IsGitRepoUrl("./local")) assert.False(t, IsGitRepoUrl("foo")) + assert.False(t, IsGitRepoUrl("github.com/databricks/cli.git")) } func TestResolveReader(t *testing.T) { From a09fed73e2c38897bd9e5d6cd2aecfe7ff3b4fa1 Mon Sep 17 00:00:00 2001 From: Jan Rose Date: Fri, 10 Jul 2026 09:46:13 +0200 Subject: [PATCH 4/4] Use test case that's not git@ prefixed SSH URL --- libs/template/resolver_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/template/resolver_test.go b/libs/template/resolver_test.go index df3e3768525..12de32ab963 100644 --- a/libs/template/resolver_test.go +++ b/libs/template/resolver_test.go @@ -104,7 +104,7 @@ func TestBundleInitIsGitRepoUrl(t *testing.T) { // Supported assert.True(t, IsGitRepoUrl("git@github.com:databricks/cli.git")) assert.True(t, IsGitRepoUrl("https://github.com/databricks/cli.git")) - assert.True(t, IsGitRepoUrl("ssh://git@github.com/databricks/cli.git")) + assert.True(t, IsGitRepoUrl("ssh://user@company.ghe.com/databricks/cli.git")) // Unsupported assert.False(t, IsGitRepoUrl("git://github.com/databricks/cli.git"))