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:
Kishore Jagannath
2023-01-09 22:15:29 +05:30
committed by GitHub
parent 9bc75c16d9
commit 772fafa892
3 changed files with 128 additions and 127 deletions

View File

@@ -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",
},
},
}