mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
Replace git cloner with go getter to support various target
This commit is contained in:
@@ -164,30 +164,49 @@ func (fl *fileLoader) New(path string) (ifc.Loader, error) {
|
||||
if path == "" {
|
||||
return nil, fmt.Errorf("new root cannot be empty")
|
||||
}
|
||||
repoSpec, err := git.NewRepoSpecFromUrl(path)
|
||||
if err == nil {
|
||||
// Treat this as git repo clone request.
|
||||
|
||||
root, errD := func() (filesys.ConfirmedDir, error) {
|
||||
if filepath.IsAbs(path) {
|
||||
return "", fmt.Errorf("new root '%s' cannot be absolute", path)
|
||||
}
|
||||
root, err := demandDirectoryRoot(fl.fSys, fl.root.Join(path))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := fl.errIfGitContainmentViolation(root); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := fl.errIfArgEqualOrHigher(root); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return root, nil
|
||||
}()
|
||||
|
||||
if errD == nil {
|
||||
return newLoaderAtConfirmedDir(
|
||||
fl.loadRestrictor, root, fl.fSys, fl, fl.cloner), nil
|
||||
}
|
||||
|
||||
ldr, errL := func() (ifc.Loader, error) {
|
||||
repoSpec, err := git.NewRepoSpecFromUrl(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := fl.errIfRepoCycle(repoSpec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return newLoaderAtGitClone(
|
||||
repoSpec, fl.fSys, fl, fl.cloner)
|
||||
ldr, err := newLoaderAtGitClone(repoSpec, fl.fSys, fl, fl.cloner)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Error create loader: %s", err)
|
||||
}
|
||||
return ldr, nil
|
||||
}()
|
||||
|
||||
if errL == nil {
|
||||
return ldr, nil
|
||||
}
|
||||
if filepath.IsAbs(path) {
|
||||
return nil, fmt.Errorf("new root '%s' cannot be absolute", path)
|
||||
}
|
||||
root, err := demandDirectoryRoot(fl.fSys, fl.root.Join(path))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := fl.errIfGitContainmentViolation(root); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := fl.errIfArgEqualOrHigher(root); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return newLoaderAtConfirmedDir(
|
||||
fl.loadRestrictor, root, fl.fSys, fl, fl.cloner), nil
|
||||
return nil, fmt.Errorf("cannot load at directory %q nor load at git clone %q", errD, errL)
|
||||
}
|
||||
|
||||
// newLoaderAtGitClone returns a new Loader pinned to a temporary
|
||||
|
||||
Reference in New Issue
Block a user