func (t *TestFixture) Cleanup() []error {
	var errs []error
	for rcName := range t.rcs {
		ginkgo.By("stopping RC " + rcName + " in namespace " + t.Namespace)
		err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
			// First, resize the RC to 0.
			old, err := t.Client.CoreV1().ReplicationControllers(t.Namespace).Get(context.TODO(), rcName, metav1.GetOptions{})
			if err != nil {
				if apierrors.IsNotFound(err) {
					return nil
				}
				return err
			}
			x := int32(0)
			old.Spec.Replicas = &x
			if _, err := t.Client.CoreV1().ReplicationControllers(t.Namespace).Update(context.TODO(), old, metav1.UpdateOptions{}); err != nil {
				if apierrors.IsNotFound(err) {
					return nil
				}
				return err
			}
			return nil
		})
		if err != nil {
			errs = append(errs, err)
		}
		// TODO(mikedanese): Wait.
		// Then, delete the RC altogether.
		if err := t.Client.CoreV1().ReplicationControllers(t.Namespace).Delete(context.TODO(), rcName, metav1.DeleteOptions{}); err != nil {
			if !apierrors.IsNotFound(err) {
				errs = append(errs, err)
			}
		}
	}

	for serviceName := range t.services {
		ginkgo.By("deleting service " + serviceName + " in namespace " + t.Namespace)
		err := t.Client.CoreV1().Services(t.Namespace).Delete(context.TODO(), serviceName, metav1.DeleteOptions{})
		if err != nil {
			if !apierrors.IsNotFound(err) {
				errs = append(errs, err)
			}
		}
	}

	return errs
}
// Cleanup cleans all ReplicationControllers and Services which this object holds.
Cleanup cleans all ReplicationControllers and Services which this object holds.
// Cleanup cleans all ReplicationControllers and Services which this object holds .
func (t *TestFixture) Cleanup() []error {
	var errs []error
	for rcName := range t.rcs {
		ginkgo.By("stopping RC " + rcName + " in namespace " + t.Namespace)
		err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
			old, err := t.Client.CoreV1().ReplicationControllers(t.Namespace).Get(context.TODO(), rcName, metav1.GetOptions{})
			if err != nil {
				if apierrors.IsNotFound(err) {
					return nil
				}
				return err
			}
			x := int32(0)
			old.Spec.Replicas = &x
			if _, err := t.Client.CoreV1().ReplicationControllers(t.Namespace).Update(context.TODO(), old, metav1.UpdateOptions{}); err != nil {
				if apierrors.IsNotFound(err) {
					return nil
				}
				return err
			}
			return nil
		})
		if err != nil {
			errs = append(errs, err)
		}
		if err := t.Client.CoreV1().ReplicationControllers(t.Namespace).Delete(context.TODO(), rcName, metav1.DeleteOptions{}); err != nil {
			if !apierrors.IsNotFound(err) {
				errs = append(errs, err)
			}
		}
	}
	for serviceName := range t.services {
		ginkgo.By("deleting service " + serviceName + " in namespace " + t.Namespace)
		err := t.Client.CoreV1().Services(t.Namespace).Delete(context.TODO(), serviceName, metav1.DeleteOptions{})
		if err != nil {
			if !apierrors.IsNotFound(err) {
				errs = append(errs, err)
			}
		}
	}
	return errs
}
func ( t * TestFixture ) Cleanup ( ) [ ] error { var errs [ ] error for rcName := range t . rcs { ginkgo . By ( " " + rcName + " " + t . Namespace ) err := retry . RetryOnConflict ( retry . DefaultRetry , func ( ) error { old , err := t . Client . CoreV1 ( ) . ReplicationControllers ( t . Namespace ) . Get ( context . TODO ( ) , rcName , metav1 . GetOptions { } ) if err != nil { if apierrors . IsNotFound ( err ) { return nil } return err } x := int32 ( 0 ) old . Spec . Replicas = & x if _ , err := t . Client . CoreV1 ( ) . ReplicationControllers ( t . Namespace ) . Update ( context . TODO ( ) , old , metav1 . UpdateOptions { } ) ; err != nil { if apierrors . IsNotFound ( err ) { return nil } return err } return nil } ) if err != nil { errs = append ( errs , err ) } if err := t . Client . CoreV1 ( ) . ReplicationControllers ( t . Namespace ) . Delete ( context . TODO ( ) , rcName , metav1 . DeleteOptions { } ) ; err != nil { if ! apierrors . IsNotFound ( err ) { errs = append ( errs , err ) } } } for serviceName := range t . services { ginkgo . By ( " " + serviceName + " " + t . Namespace ) err := t . Client . CoreV1 ( ) . Services ( t . Namespace ) . Delete ( context . TODO ( ) , serviceName , metav1 . DeleteOptions { } ) if err != nil { if ! apierrors . IsNotFound ( err ) { errs = append ( errs , err ) } } } return errs }
Cleanup cleans all ReplicationControllers and Services which this object holds.
Cleanup cleans all ReplicationControllers and Services which this object holds .
// First, resize the RC to 0. // TODO(mikedanese): Wait. // Then, delete the RC altogether.