Move the GC checksum from labels to annotations#362
Move the GC checksum from labels to annotations#362stefanprodan merged 1 commit intofluxcd:mainfrom JaneLiuL:main
Conversation
|
@JaneLiuL I found some serious issues with |
| // --- /tmp/LIVE-656588208/kustomize.toolkit.fluxcd.io.v1beta1.Kustomization.namespace.name 2021-06-07 12:58:20.738794982 +0200 | ||
| // +++ /tmp/MERGED-532750671/kustomize.toolkit.fluxcd.io.v1beta1.Kustomization.namespace.name 2021-06-07 12:58:20.798795908 +0200 | ||
| // @@ -0,0 +1,36 @@ | ||
| func parseDiffOutput(in []byte) map[string]string { |
There was a problem hiding this comment.
Please remove this as it's unrelated to this PR.
| "crypto/sha1" | ||
| "encoding/json" | ||
| "fmt" | ||
| "github.com/fluxcd/pkg/apis/kustomize" |
There was a problem hiding this comment.
This needs to be added further down, the first import section is for Go std lib.
| } | ||
| } | ||
| if !exists { | ||
| //kus.Transformers = append(kus.Transformers, transformerFileName) |
There was a problem hiding this comment.
Please remove these commented lines.
| } | ||
| } | ||
|
|
||
| changeSet := "" |
There was a problem hiding this comment.
This change is unrelated to this PR please undo it.
| return changeSet, true | ||
| } | ||
|
|
||
| // We can't drop the label check in this version. |
There was a problem hiding this comment.
Please replace this with:
Check both labels and annotations for the checksum to preserve backwards compatibility
| func (kg *KustomizeGenerator) generateLabelTransformer(checksum, dirPath string) error { | ||
| labels := selectorLabels(kg.kustomization.GetName(), kg.kustomization.GetNamespace()) | ||
|
|
||
| // add checksum label only if GC is enabled |
There was a problem hiding this comment.
This has been lost, please restore it for the annotions
| return err | ||
| } | ||
|
|
||
| labelsFile := filepath.Join(dirPath, transformerAnnotationFileName) |
There was a problem hiding this comment.
| labelsFile := filepath.Join(dirPath, transformerAnnotationFileName) | |
| annotationsFile := filepath.Join(dirPath, transformerAnnotationFileName) |
| const ( | ||
| transformerFileName = "kustomization-gc-labels.yaml" | ||
| transformerFileName = "kustomization-gc-labels.yaml" | ||
| transformerAnnotationFileName = "kustomization-annotation-labels.yaml" |
There was a problem hiding this comment.
| transformerAnnotationFileName = "kustomization-annotation-labels.yaml" | |
| transformerAnnotationFileName = "kustomization-gc-annotations.yaml" |
Signed-off-by: Jane Liu L <jane.l.liu@ericsson.com>
This PR moves the
kustomize.toolkit.fluxcd.io/checksumfrom labels to annotations. This should fix any conflicts with 3rd party controllers like Stash (fix: #315) that are copying the labels from their custom resources to generated objects.