Skip to content

Commit 108d836

Browse files
committed
Populate source-revision across all the resources at apply
Signed-off-by: Adrian Fernandez De La Torre <[email protected]>
1 parent 0c36aa0 commit 108d836

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

internal/controller/kustomization_controller.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,24 @@ func (r *KustomizationReconciler) apply(ctx context.Context,
803803
return false, nil, err
804804
}
805805

806-
if cmeta := obj.Spec.CommonMetadata; cmeta != nil {
806+
cmeta := obj.Spec.CommonMetadata
807+
revisionAnnotations := map[string]string{
808+
fmt.Sprintf("%s/source-revision", eventv1.Group): revision,
809+
}
810+
if originRevision != "" {
811+
revisionAnnotations[fmt.Sprintf("%s/source-revision", eventv1.Group)] = originRevision
812+
}
813+
814+
if cmeta != nil {
815+
if cmeta.Annotations == nil {
816+
cmeta.Annotations = make(map[string]string)
817+
}
818+
for k, v := range revisionAnnotations {
819+
cmeta.Annotations[k] = v
820+
}
807821
ssautil.SetCommonMetadata(objects, cmeta.Labels, cmeta.Annotations)
822+
} else {
823+
ssautil.SetCommonMetadata(objects, nil, revisionAnnotations)
808824
}
809825

810826
applyOpts := ssa.DefaultApplyOptions()

0 commit comments

Comments
 (0)