@@ -720,26 +720,9 @@ func (d *ResourceDetector) GetUnstructuredObject(objectKey keys.ClusterWideKey)
720
720
return unstructuredObj , nil
721
721
}
722
722
723
- func (d * ResourceDetector ) getPropagationPolicyID (policy * policyv1alpha1.PropagationPolicy ) (string , error ) {
724
- id := util .GetLabelValue (policy .GetLabels (), policyv1alpha1 .PropagationPolicyPermanentIDLabel )
725
- if id == "" {
726
- id = uuid .New ().String ()
727
- policy .Labels = util .DedupeAndMergeLabels (policy .Labels , map [string ]string {policyv1alpha1 .PropagationPolicyPermanentIDLabel : id })
728
- if err := d .Client .Update (context .TODO (), policy ); err != nil {
729
- return id , err
730
- }
731
- }
732
-
733
- return id , nil
734
- }
735
-
736
723
// ClaimPolicyForObject set policy identifier which the object associated with.
737
724
func (d * ResourceDetector ) ClaimPolicyForObject (object * unstructured.Unstructured , policy * policyv1alpha1.PropagationPolicy ) (string , error ) {
738
- policyID , err := d .getPropagationPolicyID (policy )
739
- if err != nil {
740
- klog .Errorf ("Get PropagationPolicy(%s/%s) ID error:%v" , policy .Namespace , policy .Name , err )
741
- return "" , err
742
- }
725
+ policyID := policy .Labels [policyv1alpha1 .PropagationPolicyPermanentIDLabel ]
743
726
744
727
objLabels := object .GetLabels ()
745
728
if objLabels == nil {
@@ -770,26 +753,9 @@ func (d *ResourceDetector) ClaimPolicyForObject(object *unstructured.Unstructure
770
753
return policyID , d .Client .Update (context .TODO (), objectCopy )
771
754
}
772
755
773
- func (d * ResourceDetector ) getClusterPropagationPolicyID (policy * policyv1alpha1.ClusterPropagationPolicy ) (string , error ) {
774
- id := util .GetLabelValue (policy .GetLabels (), policyv1alpha1 .ClusterPropagationPolicyPermanentIDLabel )
775
- if id == "" {
776
- id = uuid .New ().String ()
777
- policy .Labels = util .DedupeAndMergeLabels (policy .Labels , map [string ]string {policyv1alpha1 .ClusterPropagationPolicyPermanentIDLabel : id })
778
- if err := d .Client .Update (context .TODO (), policy ); err != nil {
779
- return "" , err
780
- }
781
- }
782
-
783
- return id , nil
784
- }
785
-
786
756
// ClaimClusterPolicyForObject set cluster identifier which the object associated with
787
757
func (d * ResourceDetector ) ClaimClusterPolicyForObject (object * unstructured.Unstructured , policy * policyv1alpha1.ClusterPropagationPolicy ) (string , error ) {
788
- policyID , err := d .getClusterPropagationPolicyID (policy )
789
- if err != nil {
790
- klog .Errorf ("Get ClusterPropagationPolicy(%s) ID error:%v" , policy .Name , err )
791
- return "" , err
792
- }
758
+ policyID := policy .Labels [policyv1alpha1 .ClusterPropagationPolicyPermanentIDLabel ]
793
759
794
760
claimedID := util .GetLabelValue (object .GetLabels (), policyv1alpha1 .ClusterPropagationPolicyPermanentIDLabel )
795
761
// object has been claimed, don't need to claim again
0 commit comments