mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-18 02:01:29 +00:00
add to BuildAnnotations
This commit is contained in:
@@ -42,9 +42,12 @@ var BuildAnnotations = []string{
|
|||||||
kioutil.PathAnnotation,
|
kioutil.PathAnnotation,
|
||||||
kioutil.IndexAnnotation,
|
kioutil.IndexAnnotation,
|
||||||
kioutil.SeqIndentAnnotation,
|
kioutil.SeqIndentAnnotation,
|
||||||
|
kioutil.IdAnnotation,
|
||||||
|
kioutil.InternalAnnotationsMigrationResourceIDAnnotation,
|
||||||
|
|
||||||
kioutil.LegacyPathAnnotation,
|
kioutil.LegacyPathAnnotation,
|
||||||
kioutil.LegacyIndexAnnotation,
|
kioutil.LegacyIndexAnnotation,
|
||||||
|
kioutil.LegacyIdAnnotation,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resource) ResetRNode(incoming *Resource) {
|
func (r *Resource) ResetRNode(incoming *Resource) {
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ import (
|
|||||||
"sigs.k8s.io/kustomize/kyaml/yaml"
|
"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.
|
// Reader reads ResourceNodes. Analogous to io.Reader.
|
||||||
type Reader interface {
|
type Reader interface {
|
||||||
Read() ([]*yaml.RNode, error)
|
Read() ([]*yaml.RNode, error)
|
||||||
@@ -178,7 +174,7 @@ func PreprocessResourcesForInternalAnnotationMigration(result []*yaml.RNode) (ma
|
|||||||
idToAnnosMap := make(map[string]map[string]string)
|
idToAnnosMap := make(map[string]map[string]string)
|
||||||
for i := range result {
|
for i := range result {
|
||||||
idStr := strconv.Itoa(i)
|
idStr := strconv.Itoa(i)
|
||||||
err := result[i].PipeE(yaml.SetAnnotation(resourceIDAnnotation, idStr))
|
err := result[i].PipeE(yaml.SetAnnotation(kioutil.InternalAnnotationsMigrationResourceIDAnnotation, idStr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -259,7 +255,7 @@ func ReconcileInternalAnnotations(result []*yaml.RNode, nodeAnnosMap map[string]
|
|||||||
return err
|
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
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -369,7 +365,7 @@ func checkAnnotationsAltered(rn *yaml.RNode, nodeAnnosMap map[string]map[string]
|
|||||||
id: annotations[kioutil.LegacyIdAnnotation],
|
id: annotations[kioutil.LegacyIdAnnotation],
|
||||||
}
|
}
|
||||||
|
|
||||||
rid := annotations[resourceIDAnnotation]
|
rid := annotations[kioutil.InternalAnnotationsMigrationResourceIDAnnotation]
|
||||||
originalAnnotations, found := nodeAnnosMap[rid]
|
originalAnnotations, found := nodeAnnosMap[rid]
|
||||||
if !found {
|
if !found {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ const (
|
|||||||
|
|
||||||
// Deprecated: use IdAnnotation instead.
|
// Deprecated: use IdAnnotation instead.
|
||||||
LegacyIdAnnotation = "config.k8s.io/id"
|
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) {
|
func GetFileAnnotations(rn *yaml.RNode) (string, string, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user