...

Source file src/sigs.k8s.io/kustomize/api/internal/builtins/AnnotationsTransformer.go

Documentation: sigs.k8s.io/kustomize/api/internal/builtins

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

View as plain text