...
1
2
3
4 package filters
5
6 import (
7 "sigs.k8s.io/kustomize/kyaml/yaml"
8 )
9
10 const LocalConfigAnnotation = "config.kubernetes.io/local-config"
11
12
13 type IsLocalConfig struct {
14
15 IncludeLocalConfig bool `yaml:"includeLocalConfig,omitempty"`
16
17
18 ExcludeNonLocalConfig bool `yaml:"excludeNonLocalConfig,omitempty"`
19 }
20
21
22 func (c *IsLocalConfig) Filter(inputs []*yaml.RNode) ([]*yaml.RNode, error) {
23 var out []*yaml.RNode
24 for i := range inputs {
25 meta, err := inputs[i].GetMeta()
26 if err != nil {
27 return nil, err
28 }
29 _, local := meta.Annotations[LocalConfigAnnotation]
30
31 if local && c.IncludeLocalConfig {
32 out = append(out, inputs[i])
33 } else if !local && !c.ExcludeNonLocalConfig {
34 out = append(out, inputs[i])
35 }
36 }
37 return out, nil
38 }
39
View as plain text