@@ -820,25 +820,25 @@ func (a *Operator) copyToNamespace(prototype *v1alpha1.ClusterServiceVersion, ns
820820 if _ , err := a .client .OperatorsV1alpha1 ().ClusterServiceVersions (nsTo ).UpdateStatus (context .TODO (), created , metav1.UpdateOptions {}); err != nil {
821821 return nil , fmt .Errorf ("failed to update status on new CSV: %w" , err )
822822 }
823- prototype .Annotations [statusCopyHashAnnotation ] = status
824- // persist status-hash annotation
825- updatedCreated , err := a .client .OperatorsV1alpha1 ().ClusterServiceVersions (nsTo ).Update (context .TODO (), prototype , metav1.UpdateOptions {})
826- if err != nil {
827- return nil , fmt .Errorf ("failed to update annotations after updating status: %w" , err )
828- }
829- // record observed generation and resourceVersion for metadata-drift guard
830- updatedCreated .Annotations [observedGenerationAnnotation ] = fmt .Sprint (updatedCreated .GetGeneration ())
831- updatedCreated .Annotations [observedResourceVersionAnnotation ] = updatedCreated .ResourceVersion
832- if _ , err := a .client .OperatorsV1alpha1 ().ClusterServiceVersions (nsTo ).Update (context .TODO (), updatedCreated , metav1.UpdateOptions {}); err != nil {
833- return nil , fmt .Errorf ("failed to update metadata guard annotations after creation: %w" , err )
834- }
835- return & v1alpha1.ClusterServiceVersion {
836- ObjectMeta : metav1.ObjectMeta {
837- Name : updatedCreated .Name ,
838- Namespace : updatedCreated .Namespace ,
839- UID : updatedCreated .UID ,
840- },
841- }, nil
823+ prototype .Annotations [statusCopyHashAnnotation ] = status
824+ // persist status-hash annotation
825+ updatedCreated , err := a .client .OperatorsV1alpha1 ().ClusterServiceVersions (nsTo ).Update (context .TODO (), prototype , metav1.UpdateOptions {})
826+ if err != nil {
827+ return nil , fmt .Errorf ("failed to update annotations after updating status: %w" , err )
828+ }
829+ // record observed generation and resourceVersion for metadata-drift guard
830+ updatedCreated .Annotations [observedGenerationAnnotation ] = fmt .Sprint (updatedCreated .GetGeneration ())
831+ updatedCreated .Annotations [observedResourceVersionAnnotation ] = updatedCreated .ResourceVersion
832+ if _ , err := a .client .OperatorsV1alpha1 ().ClusterServiceVersions (nsTo ).Update (context .TODO (), updatedCreated , metav1.UpdateOptions {}); err != nil {
833+ return nil , fmt .Errorf ("failed to update metadata guard annotations after creation: %w" , err )
834+ }
835+ return & v1alpha1.ClusterServiceVersion {
836+ ObjectMeta : metav1.ObjectMeta {
837+ Name : updatedCreated .Name ,
838+ Namespace : updatedCreated .Namespace ,
839+ UID : updatedCreated .UID ,
840+ },
841+ }, nil
842842 } else if err != nil {
843843 return nil , err
844844 }
@@ -904,18 +904,18 @@ func (a *Operator) copyToNamespace(prototype *v1alpha1.ClusterServiceVersion, ns
904904 }
905905 // Update the status first if the existing copied CSV status hash doesn't match what we expect
906906 // to prevent a scenario where the hash annotations match but the contents do not.
907- // persist status-hash annotation
908- prototype .Annotations [statusCopyHashAnnotation ] = status
909- updated , err = a .client .OperatorsV1alpha1 ().ClusterServiceVersions (nsTo ).Update (context .TODO (), prototype , metav1.UpdateOptions {})
910- if err != nil {
911- return nil , fmt .Errorf ("failed to update: %w" , err )
912- }
913- // record observed generation and resourceVersion for metadata-drift guard
914- updated .Annotations [observedGenerationAnnotation ] = fmt .Sprint (updated .GetGeneration ())
915- updated .Annotations [observedResourceVersionAnnotation ] = updated .ResourceVersion
916- if updated , err = a .client .OperatorsV1alpha1 ().ClusterServiceVersions (nsTo ).Update (context .TODO (), updated , metav1.UpdateOptions {}); err != nil {
917- return nil , fmt .Errorf ("failed to update metadata guard annotations after status update: %w" , err )
918- }
907+ // persist status-hash annotation
908+ prototype .Annotations [statusCopyHashAnnotation ] = status
909+ updated , err = a .client .OperatorsV1alpha1 ().ClusterServiceVersions (nsTo ).Update (context .TODO (), prototype , metav1.UpdateOptions {})
910+ if err != nil {
911+ return nil , fmt .Errorf ("failed to update: %w" , err )
912+ }
913+ // record observed generation and resourceVersion for metadata-drift guard
914+ updated .Annotations [observedGenerationAnnotation ] = fmt .Sprint (updated .GetGeneration ())
915+ updated .Annotations [observedResourceVersionAnnotation ] = updated .ResourceVersion
916+ if updated , err = a .client .OperatorsV1alpha1 ().ClusterServiceVersions (nsTo ).Update (context .TODO (), updated , metav1.UpdateOptions {}); err != nil {
917+ return nil , fmt .Errorf ("failed to update metadata guard annotations after status update: %w" , err )
918+ }
919919 } else {
920920 // Even if they're the same, ensure the returned prototype is annotated.
921921 prototype .Annotations [statusCopyHashAnnotation ] = status
0 commit comments