diff --git a/api/resource/resource.go b/api/resource/resource.go index 4985f7255..7f8bfbd7d 100644 --- a/api/resource/resource.go +++ b/api/resource/resource.go @@ -42,9 +42,12 @@ var BuildAnnotations = []string{ kioutil.PathAnnotation, kioutil.IndexAnnotation, kioutil.SeqIndentAnnotation, + kioutil.IdAnnotation, + kioutil.InternalAnnotationsMigrationResourceIDAnnotation, kioutil.LegacyPathAnnotation, kioutil.LegacyIndexAnnotation, + kioutil.LegacyIdAnnotation, } func (r *Resource) ResetRNode(incoming *Resource) { diff --git a/kyaml/kio/kio.go b/kyaml/kio/kio.go index 46047152a..10388acd3 100644 --- a/kyaml/kio/kio.go +++ b/kyaml/kio/kio.go @@ -14,10 +14,6 @@ import ( "sigs.k8s.io/kustomize/kyaml/yaml" ) -// resourceIDAnnotation is used to uniquely identify the resource during round trip -// to and from a function execution. -const resourceIDAnnotation = "internal.config.k8s.io/annotations-migration-resource-id" - // Reader reads ResourceNodes. Analogous to io.Reader. type Reader interface { Read() ([]*yaml.RNode, error) @@ -178,7 +174,7 @@ func PreprocessResourcesForInternalAnnotationMigration(result []*yaml.RNode) (ma idToAnnosMap := make(map[string]map[string]string) for i := range result { idStr := strconv.Itoa(i) - err := result[i].PipeE(yaml.SetAnnotation(resourceIDAnnotation, idStr)) + err := result[i].PipeE(yaml.SetAnnotation(kioutil.InternalAnnotationsMigrationResourceIDAnnotation, idStr)) if err != nil { return nil, err } @@ -259,7 +255,7 @@ func ReconcileInternalAnnotations(result []*yaml.RNode, nodeAnnosMap map[string] return err } - if _, err = result[i].Pipe(yaml.ClearAnnotation(resourceIDAnnotation)); err != nil { + if _, err = result[i].Pipe(yaml.ClearAnnotation(kioutil.InternalAnnotationsMigrationResourceIDAnnotation)); err != nil { return err } } @@ -369,7 +365,7 @@ func checkAnnotationsAltered(rn *yaml.RNode, nodeAnnosMap map[string]map[string] id: annotations[kioutil.LegacyIdAnnotation], } - rid := annotations[resourceIDAnnotation] + rid := annotations[kioutil.InternalAnnotationsMigrationResourceIDAnnotation] originalAnnotations, found := nodeAnnosMap[rid] if !found { return nil diff --git a/kyaml/kio/kioutil/kioutil.go b/kyaml/kio/kioutil/kioutil.go index 9f117e95a..7d1a85273 100644 --- a/kyaml/kio/kioutil/kioutil.go +++ b/kyaml/kio/kioutil/kioutil.go @@ -41,6 +41,11 @@ const ( // Deprecated: use IdAnnotation instead. LegacyIdAnnotation = "config.k8s.io/id" + + // InternalAnnotationsMigrationResourceIDAnnotation is used to uniquely identify + // resources during round trip to and from a function execution. We will use it + // to track the internal annotations and reconcile them if needed. + InternalAnnotationsMigrationResourceIDAnnotation = "internal.config.k8s.io/annotations-migration-resource-id" ) func GetFileAnnotations(rn *yaml.RNode) (string, string, error) {