// deleteIfExists deletes resources by using gvr & name & namespace, will wait for deletion to complete by using eventually
deleteIfExists deletes resources by using gvr & name & namespace, will wait for deletion to complete by using eventually
// deleteIfExists deletes resources by using gvr & name & namespace will wait for deletion to complete by using eventually
func deleteIfExists(clientHubDynamic dynamic.Interface, gvr schema.GroupVersionResource, name, namespace string) {
	ns := clientHubDynamic.Resource(gvr).Namespace(namespace)
	if _, err := ns.Get(context.TODO(), name, metav1.GetOptions{}); err != nil {
		Expect(errors.IsNotFound(err)).To(Equal(true))
		return
	}
	Expect(func() error {
		err := ns.Delete(context.TODO(), name, metav1.DeleteOptions{})
		if err != nil && !errors.IsNotFound(err) {
			return err
		}
		return nil
	}()).To(BeNil())
	By("Wait for deletion")
	Eventually(func() error {
		var err error
		_, err = ns.Get(context.TODO(), name, metav1.GetOptions{})
		if err != nil && !errors.IsNotFound(err) {
			return err
		}
		if err == nil {
			return fmt.Errorf("found object %s in namespace %s after deletion", name, namespace)
		}
		return nil
	}, 10, 1).Should(BeNil())
}
func deleteIfExists ( clientHubDynamic dynamic . Interface , gvr schema . GroupVersionResource , name , namespace string ) { ns := clientHubDynamic . Resource ( gvr ) . Namespace ( namespace ) if _ , err := ns . Get ( context . TODO ( ) , name , metav1 . GetOptions { } ) ; err != nil { Expect ( errors . IsNotFound ( err ) ) . To ( Equal ( true ) ) return } Expect ( func ( ) error { err := ns . Delete ( context . TODO ( ) , name , metav1 . DeleteOptions { } ) if err != nil && ! errors . IsNotFound ( err ) { return err } return nil } ( ) ) . To ( BeNil ( ) ) By ( " " ) Eventually ( func ( ) error { var err error _ , err = ns . Get ( context . TODO ( ) , name , metav1 . GetOptions { } ) if err != nil && ! errors . IsNotFound ( err ) { return err } if err == nil { return fmt . Errorf ( " " , name , namespace ) } return nil } , 10 , 1 ) . Should ( BeNil ( ) ) }
deleteIfExists deletes resources by using gvr & name & namespace, will wait for deletion to complete by using eventually
deleteIfExists deletes resources by using gvr & name & namespace will wait for deletion to complete by using eventually
// possibly already got deleted