mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-01 18:30:15 +00:00
Support remote resources for kustomize edit add
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"sigs.k8s.io/kustomize/api/filesys"
|
||||
"sigs.k8s.io/kustomize/api/ifc"
|
||||
)
|
||||
|
||||
// GlobPatterns accepts a slice of glob strings and returns the set of
|
||||
@@ -29,6 +30,32 @@ func GlobPatterns(fSys filesys.FileSystem, patterns []string) ([]string, error)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GlobPatterns accepts a slice of glob strings and returns the set of
|
||||
// matching file paths. If files are not found, will try load from remote.
|
||||
func GlobPatternsWithLoader(fSys filesys.FileSystem, ldr ifc.Loader, patterns []string) ([]string, error) {
|
||||
var result []string
|
||||
for _, pattern := range patterns {
|
||||
files, err := fSys.Glob(pattern)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(files) == 0 {
|
||||
loader, err := ldr.New(pattern)
|
||||
if err != nil {
|
||||
log.Printf("%s has no match", pattern)
|
||||
} else {
|
||||
result = append(result, pattern)
|
||||
if loader != nil {
|
||||
loader.Cleanup()
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
result = append(result, files...)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ConvertToMap converts a slice of strings in the form of
|
||||
// `key:value` into a map.
|
||||
func ConvertToMap(input string, kind string) (map[string]string, error) {
|
||||
|
||||
Reference in New Issue
Block a user