mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Rename Orgrepo and Path (#4922)
* initial changes to rename OrgRepo to RepoPath * changes to rename Path to KustRootPath * addressed review comments * addressed review comments * docs: Add documentation for namespace transformer Add a short description of the namespace transformer and example usage to examples/transformerconfigs/README.md. References: #629 Signed-off-by: Lars Kellogg-Stedman <lars@oddbit.com> * Localize patchesJson6902, patchesStrategicMerge, replacements (#4904) * Localize patchesJson6902, patchesStrategicMerge, replacements * Address code review feedback * Improve readability * Remove deprecation warning check * Load legacy kustomization fields for `localize` (#4918) * Load legacy kustomization * Expose loadKustFile in kusttarget * remove FixKustomizationPreUnmarshalling * remove deprecated cfg and fn commands (#4930) * remove deprecated cfg and fn commands * fix lint error * run gofmt * Localize PatchTransformer, PatchJson6902Transformer (#4920) * Localize patches, patchesJson6902 custom transformers * Improve readability * Localize fields: openapi, configurations, crds (#4907) * Localize openapi, configurations, crds * Add integration test * Move krusty test * Address code review feedback * Implement locRootPath (#4909) * Implement locRootPath, and include userinfo, port in locFilePath * Strip userinfo, port * Improve readability * Localize legacy fields * Localize resources (#4912) * Localize resources * Improve readability * Add integration tests * Group test helper functions * Remove Functionality that Pulls Env Variables from Empty Keys * Update api/kv/kv.go Co-authored-by: Katrina Verey <kn.verey@gmail.com> * refactor Unmarshal Kustomization struct code * improve error messages * Run go mod tidy on all modules before update * Update sigs.k8s.io/yaml to 1.3.0 * fixed test failure because of latest commits Signed-off-by: Lars Kellogg-Stedman <lars@oddbit.com> Co-authored-by: Lars Kellogg-Stedman <lars@oddbit.com> Co-authored-by: Anna Song <annasong@google.com> Co-authored-by: yugo kobayashi <kobdotsh@gmail.com> Co-authored-by: Natasha Sarkar <natashasarkar@google.com> Co-authored-by: Cailyn Edwards <cailyn.edwards@shopify.com> Co-authored-by: Cailyn <cailyn.s.e@gmail.com> Co-authored-by: Katrina Verey <kn.verey@gmail.com> Co-authored-by: Katrina Verey <katrina.verey@shopify.com>
This commit is contained in:
committed by
GitHub
parent
9bc75c16d9
commit
772fafa892
@@ -30,16 +30,16 @@ type RepoSpec struct {
|
||||
// Host, e.g. https://github.com/
|
||||
Host string
|
||||
|
||||
// orgRepo name (organization/repoName),
|
||||
// RepoPath name (Path to repository),
|
||||
// e.g. kubernetes-sigs/kustomize
|
||||
OrgRepo string
|
||||
RepoPath string
|
||||
|
||||
// Dir where the orgRepo is cloned to.
|
||||
// Dir is where the repository is cloned to.
|
||||
Dir filesys.ConfirmedDir
|
||||
|
||||
// Relative path in the repository, and in the cloneDir,
|
||||
// to a Kustomization.
|
||||
Path string
|
||||
KustRootPath string
|
||||
|
||||
// Branch or tag reference.
|
||||
Ref string
|
||||
@@ -57,9 +57,9 @@ type RepoSpec struct {
|
||||
// CloneSpec returns a string suitable for "git clone {spec}".
|
||||
func (x *RepoSpec) CloneSpec() string {
|
||||
if isAzureHost(x.Host) || isAWSHost(x.Host) {
|
||||
return x.Host + x.OrgRepo
|
||||
return x.Host + x.RepoPath
|
||||
}
|
||||
return x.Host + x.OrgRepo + x.GitSuffix
|
||||
return x.Host + x.RepoPath + x.GitSuffix
|
||||
}
|
||||
|
||||
func (x *RepoSpec) CloneDir() filesys.ConfirmedDir {
|
||||
@@ -71,7 +71,7 @@ func (x *RepoSpec) Raw() string {
|
||||
}
|
||||
|
||||
func (x *RepoSpec) AbsPath() string {
|
||||
return x.Dir.Join(x.Path)
|
||||
return x.Dir.Join(x.KustRootPath)
|
||||
}
|
||||
|
||||
func (x *RepoSpec) Cleaner(fSys filesys.FileSystem) func() error {
|
||||
@@ -87,13 +87,13 @@ func NewRepoSpecFromURL(n string) (*RepoSpec, error) {
|
||||
return nil, fmt.Errorf("uri looks like abs path: %s", n)
|
||||
}
|
||||
repoSpecVal := parseGitURL(n)
|
||||
if repoSpecVal.OrgRepo == "" {
|
||||
return nil, fmt.Errorf("url lacks orgRepo: %s", n)
|
||||
if repoSpecVal.RepoPath == "" {
|
||||
return nil, fmt.Errorf("url lacks repoPath: %s", n)
|
||||
}
|
||||
if repoSpecVal.Host == "" {
|
||||
return nil, fmt.Errorf("url lacks host: %s", n)
|
||||
}
|
||||
cleanedPath := filepath.Clean(strings.TrimPrefix(repoSpecVal.Path, string(filepath.Separator)))
|
||||
cleanedPath := filepath.Clean(strings.TrimPrefix(repoSpecVal.KustRootPath, string(filepath.Separator)))
|
||||
if pathElements := strings.Split(cleanedPath, string(filepath.Separator)); len(pathElements) > 0 &&
|
||||
pathElements[0] == filesys.ParentDir {
|
||||
return nil, fmt.Errorf("url path exits repo: %s", n)
|
||||
@@ -124,8 +124,8 @@ func parseGitURL(n string) *RepoSpec {
|
||||
index := strings.Index(n, gitDelimiter)
|
||||
// Adding _git/ to host
|
||||
repoSpec.Host = normalizeGitHostSpec(n[:index+len(gitDelimiter)])
|
||||
repoSpec.OrgRepo = strings.Split(n[index+len(gitDelimiter):], "/")[0]
|
||||
repoSpec.Path = parsePath(n[index+len(gitDelimiter)+len(repoSpec.OrgRepo):])
|
||||
repoSpec.RepoPath = strings.Split(n[index+len(gitDelimiter):], "/")[0]
|
||||
repoSpec.KustRootPath = parsePath(n[index+len(gitDelimiter)+len(repoSpec.RepoPath):])
|
||||
return repoSpec
|
||||
}
|
||||
repoSpec.Host, n = parseHostSpec(n)
|
||||
@@ -136,40 +136,40 @@ func parseGitURL(n string) *RepoSpec {
|
||||
if strings.Contains(n, gitSuffix) {
|
||||
repoSpec.GitSuffix = gitSuffix
|
||||
index := strings.Index(n, gitSuffix)
|
||||
repoSpec.OrgRepo = n[0:index]
|
||||
repoSpec.RepoPath = n[0:index]
|
||||
n = n[index+len(gitSuffix):]
|
||||
if len(n) > 0 && n[0] == '/' {
|
||||
n = n[1:]
|
||||
}
|
||||
repoSpec.Path = parsePath(n)
|
||||
repoSpec.KustRootPath = parsePath(n)
|
||||
return repoSpec
|
||||
}
|
||||
|
||||
if isLocal {
|
||||
if idx := strings.Index(n, "//"); idx > 0 {
|
||||
repoSpec.OrgRepo = n[:idx]
|
||||
repoSpec.RepoPath = n[:idx]
|
||||
n = n[idx+2:]
|
||||
repoSpec.Path = parsePath(n)
|
||||
repoSpec.KustRootPath = parsePath(n)
|
||||
return repoSpec
|
||||
}
|
||||
repoSpec.OrgRepo = parsePath(n)
|
||||
repoSpec.RepoPath = parsePath(n)
|
||||
return repoSpec
|
||||
}
|
||||
|
||||
i := strings.Index(n, "/")
|
||||
if i < 1 {
|
||||
repoSpec.Path = parsePath(n)
|
||||
repoSpec.KustRootPath = parsePath(n)
|
||||
return repoSpec
|
||||
}
|
||||
j := strings.Index(n[i+1:], "/")
|
||||
if j >= 0 {
|
||||
j += i + 1
|
||||
repoSpec.OrgRepo = n[:j]
|
||||
repoSpec.Path = parsePath(n[j+1:])
|
||||
repoSpec.RepoPath = n[:j]
|
||||
repoSpec.KustRootPath = parsePath(n[j+1:])
|
||||
return repoSpec
|
||||
}
|
||||
repoSpec.Path = ""
|
||||
repoSpec.OrgRepo = parsePath(n)
|
||||
repoSpec.KustRootPath = ""
|
||||
repoSpec.RepoPath = parsePath(n)
|
||||
return repoSpec
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestNewRepoSpecFromUrl_Permute(t *testing.T) {
|
||||
// Generate all many permutations of host, orgRepo, pathName, and ref.
|
||||
// Generate all many permutations of host, RepoPath, pathName, and ref.
|
||||
// Not all combinations make sense, but the parsing is very permissive and
|
||||
// we probably stil don't want to break backwards compatibility for things
|
||||
// that are unintentionally supported.
|
||||
@@ -35,15 +35,15 @@ func TestNewRepoSpecFromUrl_Permute(t *testing.T) {
|
||||
{"git@github.com:", "git@github.com:"},
|
||||
{"git@github.com/", "git@github.com:"},
|
||||
}
|
||||
var orgRepos = []string{"someOrg/someRepo", "kubernetes/website"}
|
||||
var repoPaths = []string{"someOrg/someRepo", "kubernetes/website"}
|
||||
var pathNames = []string{"README.md", "foo/krusty.txt", ""}
|
||||
var refArgs = []string{"group/version", "someBranch", "master", "v0.1.0", ""}
|
||||
|
||||
makeURL := func(hostFmt, orgRepo, path, ref string) string {
|
||||
makeURL := func(hostFmt, repoPath, path, ref string) string {
|
||||
if len(path) > 0 {
|
||||
orgRepo = filepath.Join(orgRepo, path)
|
||||
repoPath = filepath.Join(repoPath, path)
|
||||
}
|
||||
url := hostFmt + orgRepo
|
||||
url := hostFmt + repoPath
|
||||
if ref != "" {
|
||||
url += refQuery + ref
|
||||
}
|
||||
@@ -54,16 +54,16 @@ func TestNewRepoSpecFromUrl_Permute(t *testing.T) {
|
||||
for _, v := range schemeAuthority {
|
||||
hostRaw := v.raw
|
||||
hostSpec := v.normalized
|
||||
for _, orgRepo := range orgRepos {
|
||||
for _, repoPath := range repoPaths {
|
||||
for _, pathName := range pathNames {
|
||||
for _, hrefArg := range refArgs {
|
||||
t.Run(fmt.Sprintf("t%d", i), func(t *testing.T) {
|
||||
uri := makeURL(hostRaw, orgRepo, pathName, hrefArg)
|
||||
uri := makeURL(hostRaw, repoPath, pathName, hrefArg)
|
||||
rs, err := NewRepoSpecFromURL(uri)
|
||||
require.NoErrorf(t, err, "unexpected error creating RepoSpec for uri %s", uri)
|
||||
assert.Equal(t, hostSpec, rs.Host, "unexpected host for uri %s", uri)
|
||||
assert.Equal(t, orgRepo, rs.OrgRepo, "unexpected orgRepo for uri %s", uri)
|
||||
assert.Equal(t, pathName, rs.Path, "unexpected path for uri %s", uri)
|
||||
assert.Equal(t, repoPath, rs.RepoPath, "unexpected RepoPath for uri %s", uri)
|
||||
assert.Equal(t, pathName, rs.KustRootPath, "unexpected KustRootPath for uri %s", uri)
|
||||
assert.Equal(t, hrefArg, rs.Ref, "unexpected ref for uri %s", uri)
|
||||
})
|
||||
i++
|
||||
@@ -83,7 +83,7 @@ func TestNewRepoSpecFromUrlErrors(t *testing.T) {
|
||||
},
|
||||
"no_slashes": {
|
||||
"iauhsdiuashduas",
|
||||
"url lacks orgRepo",
|
||||
"url lacks repoPath",
|
||||
},
|
||||
"bad_scheme": {
|
||||
"htxxxtp://github.com/",
|
||||
@@ -91,15 +91,15 @@ func TestNewRepoSpecFromUrlErrors(t *testing.T) {
|
||||
},
|
||||
"no_org_repo": {
|
||||
"ssh://git.example.com",
|
||||
"url lacks orgRepo",
|
||||
"url lacks repoPath",
|
||||
},
|
||||
"hashicorp_git_only": {
|
||||
"git::___",
|
||||
"url lacks orgRepo",
|
||||
"url lacks repoPath",
|
||||
},
|
||||
"query_after_host": {
|
||||
"https://host?ref=group/version/minor_version",
|
||||
"url lacks orgRepo",
|
||||
"url lacks repoPath",
|
||||
},
|
||||
"path_exits_repo": {
|
||||
"https://github.com/org/repo.git//path/../../exits/repo",
|
||||
@@ -134,10 +134,10 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "https://git-codecommit.us-east-2.amazonaws.com/someorg/somerepo",
|
||||
absPath: notCloned.Join("somedir"),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "https://git-codecommit.us-east-2.amazonaws.com/",
|
||||
OrgRepo: "someorg/somerepo",
|
||||
Path: "somedir",
|
||||
GitSuffix: ".git",
|
||||
Host: "https://git-codecommit.us-east-2.amazonaws.com/",
|
||||
RepoPath: "someorg/somerepo",
|
||||
KustRootPath: "somedir",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -146,11 +146,11 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "https://git-codecommit.us-east-2.amazonaws.com/someorg/somerepo",
|
||||
absPath: notCloned.Join("somedir"),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "https://git-codecommit.us-east-2.amazonaws.com/",
|
||||
OrgRepo: "someorg/somerepo",
|
||||
Path: "somedir",
|
||||
Ref: "testbranch",
|
||||
GitSuffix: ".git",
|
||||
Host: "https://git-codecommit.us-east-2.amazonaws.com/",
|
||||
RepoPath: "someorg/somerepo",
|
||||
KustRootPath: "somedir",
|
||||
Ref: "testbranch",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -160,7 +160,7 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
absPath: notCloned.String(),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "https://fabrikops2.visualstudio.com/",
|
||||
OrgRepo: "someorg/somerepo",
|
||||
RepoPath: "someorg/somerepo",
|
||||
Ref: "master",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
@@ -171,10 +171,10 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "https://github.com/someorg/somerepo.git",
|
||||
absPath: notCloned.Join("somedir"),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "https://github.com/",
|
||||
OrgRepo: "someorg/somerepo",
|
||||
Path: "somedir",
|
||||
GitSuffix: ".git",
|
||||
Host: "https://github.com/",
|
||||
RepoPath: "someorg/somerepo",
|
||||
KustRootPath: "somedir",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -183,10 +183,10 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "git@github.com:someorg/somerepo.git",
|
||||
absPath: notCloned.Join("somedir"),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "git@github.com:",
|
||||
OrgRepo: "someorg/somerepo",
|
||||
Path: "somedir",
|
||||
GitSuffix: ".git",
|
||||
Host: "git@github.com:",
|
||||
RepoPath: "someorg/somerepo",
|
||||
KustRootPath: "somedir",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -196,7 +196,7 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
absPath: notCloned.String(),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "git@gitlab2.sqtools.ru:10022/",
|
||||
OrgRepo: "infra/kubernetes/thanos-base",
|
||||
RepoPath: "infra/kubernetes/thanos-base",
|
||||
Ref: "v0.1.0",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
@@ -207,11 +207,11 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "git@bitbucket.org:company/project.git",
|
||||
absPath: notCloned.Join("path"),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "git@bitbucket.org:company/",
|
||||
OrgRepo: "project",
|
||||
Path: "/path",
|
||||
Ref: "branch",
|
||||
GitSuffix: ".git",
|
||||
Host: "git@bitbucket.org:company/",
|
||||
RepoPath: "project",
|
||||
KustRootPath: "/path",
|
||||
Ref: "branch",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -220,8 +220,8 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "https://itfs.mycompany.com/collection/project/_git/somerepos",
|
||||
absPath: notCloned.String(),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "https://itfs.mycompany.com/collection/project/_git/",
|
||||
OrgRepo: "somerepos",
|
||||
Host: "https://itfs.mycompany.com/collection/project/_git/",
|
||||
RepoPath: "somerepos",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -230,9 +230,9 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "https://itfs.mycompany.com/collection/project/_git/somerepos",
|
||||
absPath: notCloned.String(),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "https://itfs.mycompany.com/collection/project/_git/",
|
||||
OrgRepo: "somerepos",
|
||||
Ref: "v1.0.0",
|
||||
Host: "https://itfs.mycompany.com/collection/project/_git/",
|
||||
RepoPath: "somerepos",
|
||||
Ref: "v1.0.0",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -241,10 +241,10 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "https://itfs.mycompany.com/collection/project/_git/somerepos",
|
||||
absPath: notCloned.Join("somedir"),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "https://itfs.mycompany.com/collection/project/_git/",
|
||||
OrgRepo: "somerepos",
|
||||
Path: "/somedir",
|
||||
Ref: "v1.0.0",
|
||||
Host: "https://itfs.mycompany.com/collection/project/_git/",
|
||||
RepoPath: "somerepos",
|
||||
KustRootPath: "/somedir",
|
||||
Ref: "v1.0.0",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -253,8 +253,8 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "https://itfs.mycompany.com/collection/project/_git/somerepos",
|
||||
absPath: notCloned.String(),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "https://itfs.mycompany.com/collection/project/_git/",
|
||||
OrgRepo: "somerepos",
|
||||
Host: "https://itfs.mycompany.com/collection/project/_git/",
|
||||
RepoPath: "somerepos",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -264,7 +264,7 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
absPath: notCloned.String(),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "https://bitbucket.example.com/",
|
||||
OrgRepo: "scm/project/repository",
|
||||
RepoPath: "scm/project/repository",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
},
|
||||
@@ -274,10 +274,10 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "ssh://git-codecommit.us-east-2.amazonaws.com/someorg/somerepo",
|
||||
absPath: notCloned.Join("somepath"),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "ssh://git-codecommit.us-east-2.amazonaws.com/",
|
||||
OrgRepo: "someorg/somerepo",
|
||||
Path: "somepath",
|
||||
GitSuffix: ".git",
|
||||
Host: "ssh://git-codecommit.us-east-2.amazonaws.com/",
|
||||
RepoPath: "someorg/somerepo",
|
||||
KustRootPath: "somepath",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -286,10 +286,10 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "git@github.com:someorg/somerepo.git",
|
||||
absPath: notCloned.Join("somepath"),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "git@github.com:",
|
||||
OrgRepo: "someorg/somerepo",
|
||||
Path: "somepath",
|
||||
GitSuffix: ".git",
|
||||
Host: "git@github.com:",
|
||||
RepoPath: "someorg/somerepo",
|
||||
KustRootPath: "somepath",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -298,11 +298,11 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "https://github.com/kubernetes-sigs/kustomize.git",
|
||||
absPath: notCloned.Join("/examples/multibases/dev"),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "https://github.com/",
|
||||
OrgRepo: "kubernetes-sigs/kustomize",
|
||||
Path: "/examples/multibases/dev/",
|
||||
Ref: "v1.0.6",
|
||||
GitSuffix: ".git",
|
||||
Host: "https://github.com/",
|
||||
RepoPath: "kubernetes-sigs/kustomize",
|
||||
KustRootPath: "/examples/multibases/dev/",
|
||||
Ref: "v1.0.6",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -311,11 +311,11 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "file://a/b/c/someRepo.git",
|
||||
absPath: notCloned.Join("somepath"),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "file://",
|
||||
OrgRepo: "a/b/c/someRepo",
|
||||
Path: "somepath",
|
||||
Ref: "someBranch",
|
||||
GitSuffix: ".git",
|
||||
Host: "file://",
|
||||
RepoPath: "a/b/c/someRepo",
|
||||
KustRootPath: "somepath",
|
||||
Ref: "someBranch",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -324,10 +324,10 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "file://a/b/c/someRepo",
|
||||
absPath: notCloned.Join("somepath"),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "file://",
|
||||
OrgRepo: "a/b/c/someRepo",
|
||||
Path: "somepath",
|
||||
Ref: "someBranch",
|
||||
Host: "file://",
|
||||
RepoPath: "a/b/c/someRepo",
|
||||
KustRootPath: "somepath",
|
||||
Ref: "someBranch",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -336,9 +336,9 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "file://a/b/c/someRepo",
|
||||
absPath: notCloned.String(),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "file://",
|
||||
OrgRepo: "a/b/c/someRepo",
|
||||
Ref: "someBranch",
|
||||
Host: "file://",
|
||||
RepoPath: "a/b/c/someRepo",
|
||||
Ref: "someBranch",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -347,9 +347,9 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "file:///a/b/c/someRepo",
|
||||
absPath: notCloned.String(),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "file://",
|
||||
OrgRepo: "/a/b/c/someRepo",
|
||||
Ref: "someBranch",
|
||||
Host: "file://",
|
||||
RepoPath: "/a/b/c/someRepo",
|
||||
Ref: "someBranch",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -358,11 +358,11 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "git@github.com:kubernetes-sigs/kustomize.git",
|
||||
absPath: notCloned.Join("examples/multibases/dev"),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "git@github.com:",
|
||||
OrgRepo: "kubernetes-sigs/kustomize",
|
||||
Path: "/examples/multibases/dev",
|
||||
Ref: "v1.0.6",
|
||||
GitSuffix: ".git",
|
||||
Host: "git@github.com:",
|
||||
RepoPath: "kubernetes-sigs/kustomize",
|
||||
KustRootPath: "/examples/multibases/dev",
|
||||
Ref: "v1.0.6",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -371,8 +371,8 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "file:///a/b/c/someRepo",
|
||||
absPath: notCloned.String(),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "file://",
|
||||
OrgRepo: "/a/b/c/someRepo",
|
||||
Host: "file://",
|
||||
RepoPath: "/a/b/c/someRepo",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -381,8 +381,8 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "file:///",
|
||||
absPath: notCloned.String(),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "file://",
|
||||
OrgRepo: "/",
|
||||
Host: "file://",
|
||||
RepoPath: "/",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -392,10 +392,10 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "https://fake-git-hosting.org/path/to.git",
|
||||
absPath: notCloned.Join("/examples/multibases/dev"),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "https://fake-git-hosting.org/",
|
||||
OrgRepo: "path/to/repo",
|
||||
Path: "/examples/multibases/dev",
|
||||
GitSuffix: ".git",
|
||||
Host: "https://fake-git-hosting.org/",
|
||||
RepoPath: "path/to/repo",
|
||||
KustRootPath: "/examples/multibases/dev",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -405,10 +405,10 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "ssh://alice@acme.co/path/to/repo.git",
|
||||
absPath: notCloned.Join("/examples/multibases/dev"),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "ssh://alice@acme.co",
|
||||
OrgRepo: "path/to/repo",
|
||||
Path: "/examples/multibases/dev",
|
||||
GitSuffix: ".git",
|
||||
Host: "ssh://alice@acme.co",
|
||||
RepoPath: "path/to/repo",
|
||||
KustRootPath: "/examples/multibases/dev",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -418,7 +418,7 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
absPath: notCloned.String(),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "https://authority/",
|
||||
OrgRepo: "org/repo",
|
||||
RepoPath: "org/repo",
|
||||
Ref: "group/version",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
@@ -430,7 +430,7 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
absPath: notCloned.String(),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "https://authority/",
|
||||
OrgRepo: "org/repo",
|
||||
RepoPath: "org/repo",
|
||||
Ref: "includes_git/for_some_reason",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
@@ -442,7 +442,7 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
absPath: notCloned.String(),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "https://authority/",
|
||||
OrgRepo: "org/repo",
|
||||
RepoPath: "org/repo",
|
||||
Ref: "includes.git/for_some_reason",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
@@ -453,10 +453,10 @@ func TestNewRepoSpecFromUrl_Smoke(t *testing.T) {
|
||||
cloneSpec: "https://authority/org/repo.git",
|
||||
absPath: notCloned.Join("%-invalid-uri-so-not-parsable-by-net/url.Parse"),
|
||||
repoSpec: RepoSpec{
|
||||
Host: "https://authority/",
|
||||
OrgRepo: "org/repo",
|
||||
Path: "%-invalid-uri-so-not-parsable-by-net/url.Parse",
|
||||
GitSuffix: ".git",
|
||||
Host: "https://authority/",
|
||||
RepoPath: "org/repo",
|
||||
KustRootPath: "%-invalid-uri-so-not-parsable-by-net/url.Parse",
|
||||
GitSuffix: ".git",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ func defaultNewDir(targetLdr ifc.Loader, spec *git.RepoSpec) string {
|
||||
// kustomize doesn't download repo into repo-named folder
|
||||
// must find repo folder name from url
|
||||
if repo == targetLdr.Root() {
|
||||
targetDir = urlBase(spec.OrgRepo)
|
||||
targetDir = urlBase(spec.RepoPath)
|
||||
}
|
||||
return strings.Join([]string{DstPrefix, targetDir, strings.ReplaceAll(spec.Ref, "/", "-")}, "-")
|
||||
}
|
||||
@@ -171,12 +171,13 @@ func locRootPath(rootURL, repoDir string, root filesys.ConfirmedDir, fSys filesy
|
||||
if err != nil {
|
||||
log.Panicf("cannot find path from %q to child directory %q: %s", repo, root, err)
|
||||
}
|
||||
// We do not need to escape OrgRepo, a path on the git server.
|
||||
// However, like git, we clean dot-segments from OrgRepo.
|
||||
|
||||
// We do not need to escape RepoPath, a path on the git server.
|
||||
// However, like git, we clean dot-segments from RepoPath.
|
||||
// Git does not allow ref value to contain dot-segments.
|
||||
return filepath.Join(LocalizeDir,
|
||||
host,
|
||||
filepath.Join(string(filepath.Separator), filepath.FromSlash(repoSpec.OrgRepo)),
|
||||
filepath.Join(string(filepath.Separator), filepath.FromSlash(repoSpec.RepoPath)),
|
||||
filepath.FromSlash(repoSpec.Ref),
|
||||
inRepo), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user