Skip to content

Commit

Permalink
Require relocatable kustomizations and fix some nits.
Browse files Browse the repository at this point in the history
  • Loading branch information
monopole committed Dec 7, 2018
1 parent 8a8331b commit 108b3e4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 26 deletions.
4 changes: 2 additions & 2 deletions k8sdeps/kunstruct/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ func (kf *KunstructuredFactoryImpl) Set(fs fs.FileSystem, ldr ifc.Loader) {
// validate validates that u has kind and name
func (kf *KunstructuredFactoryImpl) validate(u unstructured.Unstructured) error {
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() == "" {
return fmt.Errorf("Missing kind in object %v", u)
return fmt.Errorf("missing kind in object %v", u)
}
return nil
}
2 changes: 1 addition & 1 deletion k8sdeps/kunstruct/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func parseFields(path string) ([]string, error) {
start = i + 1
insideParentheses = false
} else {
return nil, fmt.Errorf("Invalid field path %s", path)
return nil, fmt.Errorf("invalid field path %s", path)
}
}
}
Expand Down
17 changes: 4 additions & 13 deletions pkg/loader/fileloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ import (
"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.
// It also enforces two kustomization requirements:
//
Expand Down Expand Up @@ -153,7 +148,7 @@ func (l *fileLoader) New(root string) (ifc.Loader, error) {
}
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)
}
// Get absolute path to squeeze out "..", ".", etc.
Expand Down Expand Up @@ -208,14 +203,10 @@ func (l *fileLoader) seenBefore(path string) error {
// Load returns content of file at the given relative path.
func (l *fileLoader) Load(path string) ([]byte, error) {
if filepath.IsAbs(path) {
if enforceRelocatable {
return nil, fmt.Errorf(
"must use relative path; '%s' is absolute", path)
}
} else {
path = filepath.Join(l.Root(), path)
return nil, fmt.Errorf(
"must use relative path; '%s' is absolute", path)
}
return l.fSys.ReadFile(path)
return l.fSys.ReadFile(filepath.Join(l.Root(), path))
}

// Cleanup runs the cleaner.
Expand Down
10 changes: 0 additions & 10 deletions pkg/resid/resid.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ func NewResIdWithPrefixSuffix(k gvk.Gvk, n, p, s string) ResId {
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
func NewResId(k gvk.Gvk, n string) ResId {
return ResId{gvKind: k, name: n}
Expand Down

0 comments on commit 108b3e4

Please sign in to comment.