@@ -105,10 +105,10 @@ func (c *acrService) ChangeRevision(ctx context.Context, a *application.Applicat
105105 if len (revisions ) > 0 {
106106 if app .Status .OperationState != nil && app .Status .OperationState .Operation .Sync != nil {
107107 c .logger .Infof ("Patch operation status for application %s" , app .Name )
108- patchMap = c .patchOperationSyncResultWithChangeRevision (ctx , app , revisions )
108+ patchMap = c .patchOperationSyncResultWithChangeRevision (revisions )
109109 } else {
110110 c .logger .Infof ("Patch operation for application %s" , app .Name )
111- patchMap = c .patchOperationWithChangeRevision (ctx , app , revisions )
111+ patchMap = c .patchOperationWithChangeRevision (revisions )
112112 }
113113 }
114114 if useAnnotations {
@@ -125,10 +125,9 @@ func (c *acrService) ChangeRevision(ctx context.Context, a *application.Applicat
125125 }
126126 _ , err = c .applicationClientset .ArgoprojV1alpha1 ().Applications (a .Namespace ).Patch (ctx , a .Name , types .MergePatchType , patch , metav1.PatchOptions {})
127127 return err
128- } else {
129- c .logger .Infof ("no patch needed" )
130- return nil
131128 }
129+ c .logger .Infof ("no patch needed" )
130+ return nil
132131}
133132
134133func addPatchIfNeeded (annotations map [string ]string , currentAnnotations map [string ]string , key string , val string ) {
@@ -143,30 +142,32 @@ func (c *acrService) addAnnotationPatch(m map[string]any,
143142 changeRevision string ,
144143 changeRevisions []string ,
145144 gitRevision string ,
146- gitRevisions []string ) error {
145+ gitRevisions []string ,
146+ ) error {
147147 c .logger .Infof ("annotating application '%s', changeRevision=%s, changeRevisions=%v, gitRevision=%s, gitRevisions=%v" , a .Name , changeRevision , changeRevisions , gitRevision , gitRevisions )
148148 annotations := map [string ]string {}
149149 currentAnnotations := a .Annotations
150150
151- changeRevisionsJson , err := json .Marshal (changeRevisions )
151+ changeRevisionsJSON , err := json .Marshal (changeRevisions )
152152 if err != nil {
153- return fmt .Errorf ("Failed to marshall changeRevisions %v: %v " , changeRevisions , err )
153+ return fmt .Errorf ("failed to marshall changeRevisions %v: %w " , changeRevisions , err )
154154 }
155- gitRevisionsJson , err := json .Marshal (gitRevisions )
155+ gitRevisionsJSON , err := json .Marshal (gitRevisions )
156156 if err != nil {
157- return fmt .Errorf ("Failed to marshall gitRevisions %v: %v " , gitRevisions , err )
157+ return fmt .Errorf ("failed to marshall gitRevisions %v: %w " , gitRevisions , err )
158158 }
159159
160160 addPatchIfNeeded (annotations , currentAnnotations , CHANGE_REVISION_ANN , changeRevision )
161- addPatchIfNeeded (annotations , currentAnnotations , CHANGE_REVISIONS_ANN , string (changeRevisionsJson ))
161+ addPatchIfNeeded (annotations , currentAnnotations , CHANGE_REVISIONS_ANN , string (changeRevisionsJSON ))
162162 addPatchIfNeeded (annotations , currentAnnotations , GIT_REVISION_ANN , gitRevision )
163- addPatchIfNeeded (annotations , currentAnnotations , GIT_REVISIONS_ANN , string (gitRevisionsJson ))
163+ addPatchIfNeeded (annotations , currentAnnotations , GIT_REVISIONS_ANN , string (gitRevisionsJSON ))
164164
165165 if len (annotations ) == 0 {
166166 c .logger .Info ("no need to add annotations" )
167+ } else {
168+ c .logger .Infof ("added annotations to application %s patch: %v" , a .Name , annotations )
169+ m ["metadata" ] = map [string ]any {"annotations" : annotations }
167170 }
168- c .logger .Infof ("added annotations to application %s patch: %v" , a .Name , annotations )
169- m ["metadata" ] = map [string ]any {"annotations" : annotations }
170171 return nil
171172}
172173
@@ -184,7 +185,7 @@ func (c *acrService) calculateRevision(ctx context.Context, a *application.Appli
184185 return changeRevisionResult .Revision , nil
185186}
186187
187- func (c * acrService ) patchOperationWithChangeRevision (ctx context. Context , a * application. Application , revisions []string ) map [string ]any {
188+ func (c * acrService ) patchOperationWithChangeRevision (revisions []string ) map [string ]any {
188189 if len (revisions ) == 1 {
189190 return map [string ]any {
190191 "operation" : map [string ]any {
@@ -203,7 +204,7 @@ func (c *acrService) patchOperationWithChangeRevision(ctx context.Context, a *ap
203204 }
204205}
205206
206- func (c * acrService ) patchOperationSyncResultWithChangeRevision (ctx context. Context , a * application. Application , revisions []string ) map [string ]any {
207+ func (c * acrService ) patchOperationSyncResultWithChangeRevision (revisions []string ) map [string ]any {
207208 if len (revisions ) == 1 {
208209 return map [string ]any {
209210 "status" : map [string ]any {
0 commit comments