Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Orgrepo and Path #4922

Merged
merged 22 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6812400
initial changes to rename OrgRepo to RepoPath
kishorerj Dec 9, 2022
26eb864
changes to rename Path to KustRootPath
kishorerj Dec 9, 2022
3d8ff3a
addressed review comments
kishorerj Dec 14, 2022
08a55c6
addressed review comments
kishorerj Dec 14, 2022
304e5b1
docs: Add documentation for namespace transformer
larsks Dec 5, 2022
1e1742f
Localize patchesJson6902, patchesStrategicMerge, replacements (#4904)
annasong20 Dec 12, 2022
661ebad
Load legacy kustomization fields for `localize` (#4918)
annasong20 Dec 13, 2022
04e51ad
remove FixKustomizationPreUnmarshalling
koba1t Dec 9, 2022
761ea31
remove deprecated cfg and fn commands (#4930)
natasha41575 Dec 14, 2022
8a4efa2
Localize PatchTransformer, PatchJson6902Transformer (#4920)
annasong20 Dec 16, 2022
a0bd001
Localize fields: openapi, configurations, crds (#4907)
annasong20 Dec 22, 2022
68e0b10
Implement locRootPath (#4909)
annasong20 Dec 22, 2022
08e5eca
Localize legacy fields
annasong20 Dec 15, 2022
6736c37
Localize resources (#4912)
annasong20 Jan 5, 2023
16f2b88
Remove Functionality that Pulls Env Variables from Empty Keys
Jan 4, 2023
e0ca562
Update api/kv/kv.go
cailynse Jan 5, 2023
f8f3caa
refactor Unmarshal Kustomization struct code
koba1t Dec 13, 2022
e4a4162
improve error messages
koba1t Jan 6, 2023
1f1fabe
Run go mod tidy on all modules before update
KnVerey Jan 6, 2023
e869551
Update sigs.k8s.io/yaml to 1.3.0
KnVerey Jan 6, 2023
a0dcfeb
fixed test failure because of latest commits
kishorerj Jan 8, 2023
d6dc7e8
Merge branch 'master' into rename_orgrepo
kishorerj Jan 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions api/internal/git/repospec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
}

Expand Down
Loading