Refactor parseHostSpec

Fix ssh parsing in issue 4847
This commit is contained in:
Anna Song
2022-12-14 20:48:40 -05:00
committed by Katrina Verey
parent 772fafa892
commit fbb94584dc
2 changed files with 105 additions and 44 deletions

View File

@@ -89,6 +89,10 @@ func TestNewRepoSpecFromUrlErrors(t *testing.T) {
"htxxxtp://github.com/",
"url lacks host",
},
"bad_scp": {
"git@local/path:file/system",
"url lacks host",
},
"no_org_repo": {
"ssh://git.example.com",
"url lacks repoPath",
@@ -191,27 +195,40 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
},
{
name: "t6",
input: "git@gitlab2.sqtools.ru:10022/infra/kubernetes/thanos-base.git?ref=v0.1.0",
cloneSpec: "git@gitlab2.sqtools.ru:10022/infra/kubernetes/thanos-base.git",
input: "git@gitlab2.sqtools.ru:infra/kubernetes/thanos-base.git?ref=v0.1.0",
cloneSpec: "git@gitlab2.sqtools.ru:infra/kubernetes/thanos-base.git",
absPath: notCloned.String(),
repoSpec: RepoSpec{
Host: "git@gitlab2.sqtools.ru:10022/",
RepoPath: "infra/kubernetes/thanos-base",
Host: "git@gitlab2.sqtools.ru:",
RepoPath: "infra/kubernetes/thanos-base",
Ref: "v0.1.0",
GitSuffix: ".git",
},
},
{
name: "t7",
name: "non-github_scp",
input: "git@bitbucket.org:company/project.git//path?ref=branch",
cloneSpec: "git@bitbucket.org:company/project.git",
absPath: notCloned.Join("path"),
repoSpec: RepoSpec{
Host: "git@bitbucket.org:company/",
RepoPath: "project",
KustRootPath: "/path",
Ref: "branch",
GitSuffix: ".git",
Host: "git@bitbucket.org:",
RepoPath: "company/project",
KustRootPath: "/path",
Ref: "branch",
GitSuffix: ".git",
},
},
{
name: "non-github_git-user_ssh",
input: "ssh://git@bitbucket.org/company/project.git//path?ref=branch",
cloneSpec: "ssh://git@bitbucket.org/company/project.git",
absPath: notCloned.Join("path"),
repoSpec: RepoSpec{
Host: "ssh://git@bitbucket.org/",
RepoPath: "company/project",
KustRootPath: "/path",
Ref: "branch",
GitSuffix: ".git",
},
},
{