add an option to include local configs

This commit is contained in:
Donny Xia
2021-06-01 13:38:36 -07:00
parent d9435bd1b1
commit b1fda3d62e
2 changed files with 14 additions and 8 deletions

View File

@@ -22,6 +22,11 @@ import (
// Factory makes instances of Resource.
type Factory struct {
hasher ifc.KustHasher
// IncludeLocalConfigs indicates should resource factory ignore
// the resources which have annotation 'config.kubernetes.io/local-config'.
// By default it's false.
IncludeLocalConfigs bool
}
// NewFactory makes an instance of Factory.
@@ -221,13 +226,15 @@ func (rf *Factory) shouldIgnore(n *yaml.RNode) (bool, error) {
if n.IsNilOrEmpty() {
return true, nil
}
md, err := n.GetValidatedMetadata()
if err != nil {
return true, err
}
_, ignore := md.ObjectMeta.Annotations[konfig.IgnoredByKustomizeAnnotation]
if ignore {
return true, nil
if !rf.IncludeLocalConfigs {
md, err := n.GetValidatedMetadata()
if err != nil {
return true, err
}
_, ignore := md.ObjectMeta.Annotations[konfig.IgnoredByKustomizeAnnotation]
if ignore {
return true, nil
}
}
if foundNil, path := n.HasNilEntryInList(); foundNil {
return true, fmt.Errorf("empty item at %v in object %v", path, n)