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