-
Notifications
You must be signed in to change notification settings - Fork 23
/
annotations.go
36 lines (29 loc) · 942 Bytes
/
annotations.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package transformers
import (
"github.com/ContainerSolutions/helm-convert/pkg/types"
"github.com/ContainerSolutions/helm-convert/pkg/utils"
ktypes "sigs.k8s.io/kustomize/pkg/types"
)
type annotationsTransformer struct {
keys []string
}
var _ Transformer = &annotationsTransformer{}
// NewAnnotationsTransformer constructs a annotationsTransformer.
func NewAnnotationsTransformer(keys []string) Transformer {
return &annotationsTransformer{keys}
}
// Transform remove given annotations from manifests
func (t *annotationsTransformer) Transform(config *ktypes.Kustomization, resources *types.Resources) error {
// TODO: retrieve common annotations for config.CommonAnnotations
RESOURCES_LOOP:
for id := range resources.ResMap {
obj := resources.ResMap[id].Map()
for _, key := range t.keys {
err := utils.RecursivelyRemoveKey("annotations", key, obj)
if err != nil {
continue RESOURCES_LOOP
}
}
}
return nil
}