// ensureDeleteInstanceForDeployment ensures that the instance referenced by this deployment is deleted.
ensureDeleteInstanceForDeployment ensures that the instance referenced by this deployment is deleted.
// ensureDeleteInstanceForDeployment ensures that the instance referenced by this deployment is deleted .
func (c *Controller) ensureDeleteInstanceForDeployment(ctx context.Context, log logr.Logger, deployment *lssv1alpha1.LandscaperDeployment) (bool, error) {
	log.Info("Delete instance for landscaper deployment")
	instance := &lssv1alpha1.Instance{}
	if err := c.Client().Get(ctx, deployment.Status.InstanceRef.NamespacedName(), instance); err != nil {
		if apierrors.IsNotFound(err) {
			deployment.Status.InstanceRef = nil
			if err := c.Client().Status().Update(ctx, deployment); err != nil {
				return false, fmt.Errorf("unable to remove instance reference: %w", err)
			}
			return true, nil
		} else {
			return false, fmt.Errorf("unable to get instance for deployment: %w", err)
		}
	}
	if instance.GetDeletionTimestamp().IsZero() {
		if err := c.Client().Delete(ctx, instance); err != nil {
			return false, fmt.Errorf("unable to delete instance: %w", err)
		}
	}
	return false, nil
}
func ( c * Controller ) ensureDeleteInstanceForDeployment ( ctx context . Context , log logr . Logger , deployment * lssv1alpha1 . LandscaperDeployment ) ( bool , error ) { log . Info ( " " ) instance := & lssv1alpha1 . Instance { } if err := c . Client ( ) . Get ( ctx , deployment . Status . InstanceRef . NamespacedName ( ) , instance ) ; err != nil { if apierrors . IsNotFound ( err ) { deployment . Status . InstanceRef = nil if err := c . Client ( ) . Status ( ) . Update ( ctx , deployment ) ; err != nil { return false , fmt . Errorf ( " " , err ) } return true , nil } else { return false , fmt . Errorf ( " " , err ) } } if instance . GetDeletionTimestamp ( ) . IsZero ( ) { if err := c . Client ( ) . Delete ( ctx , instance ) ; err != nil { return false , fmt . Errorf ( " " , err ) } } return false , nil }
ensureDeleteInstanceForDeployment ensures that the instance referenced by this deployment is deleted.
ensureDeleteInstanceForDeployment ensures that the instance referenced by this deployment is deleted .