@@ -194,9 +194,9 @@ func ObtainBindingSpecExistingClusters(bindingSpec workv1alpha2.ResourceBindingS
194
194
195
195
// FindOrphanWorks retrieves all works that labeled with current binding(ResourceBinding or ClusterResourceBinding) objects,
196
196
// then pick the works that not meet current binding declaration.
197
- func FindOrphanWorks (c client.Client , bindingNamespace , bindingName string , expectClusters sets.Set [string ]) ([]workv1alpha1.Work , error ) {
197
+ func FindOrphanWorks (c client.Client , bindingNamespace , bindingName , bindingID string , expectClusters sets.Set [string ]) ([]workv1alpha1.Work , error ) {
198
198
var needJudgeWorks []workv1alpha1.Work
199
- workList , err := GetWorksByBindingNamespaceName (c , bindingNamespace , bindingName )
199
+ workList , err := GetWorksByBindingID (c , bindingID , bindingNamespace != "" )
200
200
if err != nil {
201
201
klog .Errorf ("Failed to get works by binding object (%s/%s): %v" , bindingNamespace , bindingName , err )
202
202
return nil , err
@@ -344,21 +344,11 @@ func GetResourceBindings(c client.Client, ls labels.Set) (*workv1alpha2.Resource
344
344
return bindings , c .List (context .TODO (), bindings , listOpt )
345
345
}
346
346
347
- // DeleteWorkByRBNamespaceAndName will delete all Work objects by ResourceBinding namespace and name.
348
- func DeleteWorkByRBNamespaceAndName (c client.Client , namespace , name string ) error {
349
- return DeleteWorks (c , namespace , name )
350
- }
351
-
352
- // DeleteWorkByCRBName will delete all Work objects by ClusterResourceBinding name.
353
- func DeleteWorkByCRBName (c client.Client , name string ) error {
354
- return DeleteWorks (c , "" , name )
355
- }
356
-
357
347
// DeleteWorks will delete all Work objects by labels.
358
- func DeleteWorks (c client.Client , namespace , name string ) error {
359
- workList , err := GetWorksByBindingNamespaceName (c , namespace , name )
348
+ func DeleteWorks (c client.Client , namespace , name , bindingID string ) error {
349
+ workList , err := GetWorksByBindingID (c , bindingID , namespace != "" )
360
350
if err != nil {
361
- klog .Errorf ("Failed to get works by ResourceBinding(%s/%s) : %v" , namespace , name , err )
351
+ klog .Errorf ("Failed to get works by (Cluster) ResourceBinding(%s/%s) : %v" , namespace , name , err )
362
352
return err
363
353
}
364
354
0 commit comments