mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
Require relocatable kustomizations and fix some nits.
This commit is contained in:
@@ -103,10 +103,10 @@ func (kf *KunstructuredFactoryImpl) Set(fs fs.FileSystem, ldr ifc.Loader) {
|
|||||||
// validate validates that u has kind and name
|
// validate validates that u has kind and name
|
||||||
func (kf *KunstructuredFactoryImpl) validate(u unstructured.Unstructured) error {
|
func (kf *KunstructuredFactoryImpl) validate(u unstructured.Unstructured) error {
|
||||||
if u.GetName() == "" {
|
if u.GetName() == "" {
|
||||||
return fmt.Errorf("Missing metadata.name in object %v", u)
|
return fmt.Errorf("missing metadata.name in object %v", u)
|
||||||
}
|
}
|
||||||
if u.GetKind() == "" {
|
if u.GetKind() == "" {
|
||||||
return fmt.Errorf("Missing kind in object %v", u)
|
return fmt.Errorf("missing kind in object %v", u)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ func parseFields(path string) ([]string, error) {
|
|||||||
start = i + 1
|
start = i + 1
|
||||||
insideParentheses = false
|
insideParentheses = false
|
||||||
} else {
|
} else {
|
||||||
return nil, fmt.Errorf("Invalid field path %s", path)
|
return nil, fmt.Errorf("invalid field path %s", path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,11 +26,6 @@ import (
|
|||||||
"sigs.k8s.io/kustomize/pkg/ifc"
|
"sigs.k8s.io/kustomize/pkg/ifc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: 2018/Nov/20 remove this before next release.
|
|
||||||
// Leave only the true path. Retaining only for
|
|
||||||
// quick revert.
|
|
||||||
const enforceRelocatable = true
|
|
||||||
|
|
||||||
// fileLoader loads files, returning an array of bytes.
|
// fileLoader loads files, returning an array of bytes.
|
||||||
// It also enforces two kustomization requirements:
|
// It also enforces two kustomization requirements:
|
||||||
//
|
//
|
||||||
@@ -153,7 +148,7 @@ func (l *fileLoader) New(root string) (ifc.Loader, error) {
|
|||||||
}
|
}
|
||||||
return newGitLoader(root, l.fSys, l.roots, l.cloner)
|
return newGitLoader(root, l.fSys, l.roots, l.cloner)
|
||||||
}
|
}
|
||||||
if enforceRelocatable && filepath.IsAbs(root) {
|
if filepath.IsAbs(root) {
|
||||||
return nil, fmt.Errorf("new root '%s' cannot be absolute", root)
|
return nil, fmt.Errorf("new root '%s' cannot be absolute", root)
|
||||||
}
|
}
|
||||||
// Get absolute path to squeeze out "..", ".", etc.
|
// Get absolute path to squeeze out "..", ".", etc.
|
||||||
@@ -208,14 +203,10 @@ func (l *fileLoader) seenBefore(path string) error {
|
|||||||
// Load returns content of file at the given relative path.
|
// Load returns content of file at the given relative path.
|
||||||
func (l *fileLoader) Load(path string) ([]byte, error) {
|
func (l *fileLoader) Load(path string) ([]byte, error) {
|
||||||
if filepath.IsAbs(path) {
|
if filepath.IsAbs(path) {
|
||||||
if enforceRelocatable {
|
return nil, fmt.Errorf(
|
||||||
return nil, fmt.Errorf(
|
"must use relative path; '%s' is absolute", path)
|
||||||
"must use relative path; '%s' is absolute", path)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
path = filepath.Join(l.Root(), path)
|
|
||||||
}
|
}
|
||||||
return l.fSys.ReadFile(path)
|
return l.fSys.ReadFile(filepath.Join(l.Root(), path))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup runs the cleaner.
|
// Cleanup runs the cleaner.
|
||||||
|
|||||||
@@ -63,16 +63,6 @@ func NewResIdWithPrefixSuffix(k gvk.Gvk, n, p, s string) ResId {
|
|||||||
return ResId{gvKind: k, name: n, prefix: p, suffix: s}
|
return ResId{gvKind: k, name: n, prefix: p, suffix: s}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewResIdWithPrefix creates new resource identifier with a prefix
|
|
||||||
func NewResIdWithPrefix(k gvk.Gvk, n, p string) ResId {
|
|
||||||
return ResId{gvKind: k, name: n, prefix: p}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewResIdWithSuffix creates new resource identifier with a suffix
|
|
||||||
func NewResIdWithSuffix(k gvk.Gvk, n, s string) ResId {
|
|
||||||
return ResId{gvKind: k, name: n, suffix: s}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewResId creates new resource identifier
|
// NewResId creates new resource identifier
|
||||||
func NewResId(k gvk.Gvk, n string) ResId {
|
func NewResId(k gvk.Gvk, n string) ResId {
|
||||||
return ResId{gvKind: k, name: n}
|
return ResId{gvKind: k, name: n}
|
||||||
|
|||||||
Reference in New Issue
Block a user