Debian Codegraph @

api/internal/builtins/LabelTransformer.go

raw
1 // Code generated by pluginator on LabelTransformer; DO NOT EDIT.
2 package builtins
3
4 import (
5 "sigs.k8s.io/kustomize/api/filters/labels"
6 "sigs.k8s.io/kustomize/api/resmap"
7 "sigs.k8s.io/kustomize/api/types"
8 "sigs.k8s.io/yaml"
9 )
10
11 // Add the given labels to the given field specifications.
12 type LabelTransformerPlugin struct {
13 Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
14 FieldSpecs []types.FieldSpec `json:"fieldSpecs,omitempty" yaml:"fieldSpecs,omitempty"`
15 }
16
17 func (p *LabelTransformerPlugin) Config(
18 _ *resmap.PluginHelpers, c []byte) (err error) {
19 p.Labels = nil
20 p.FieldSpecs = nil
21 return yaml.Unmarshal(c, p)
22 }
23
24 func (p *LabelTransformerPlugin) Transform(m resmap.ResMap) error {
25 if len(p.Labels) == 0 {
26 return nil
27 }
28 return m.ApplyFilter(labels.Filter{
29 Labels: p.Labels,
30 FsSlice: p.FieldSpecs,
31 })
32 }
33
34 func NewLabelTransformerPlugin() resmap.TransformerPlugin {
35 return &LabelTransformerPlugin{}
36 }