// ensureDeleteInstallationForInstance ensures that the installation for an instance is deleted
ensureDeleteInstallationForInstance ensures that the installation for an instance is deleted
// ensureDeleteInstallationForInstance ensures that the installation for an instance is deleted
func (c *Controller) ensureDeleteInstallationForInstance(ctx context.Context, log logr.Logger, instance *lssv1alpha1.Instance) (bool, error) {
	log.Info("Delete installation for instance")
	installation := &lsv1alpha1.Installation{}
	if err := c.Client().Get(ctx, instance.Status.InstallationRef.NamespacedName(), installation); err != nil {
		if apierrors.IsNotFound(err) {
			instance.Status.InstallationRef = nil
			if err := c.Client().Status().Update(ctx, instance); err != nil {
				return false, fmt.Errorf("failed to remove installation reference: %w", err)
			}
			return true, nil
		} else {
			return false, fmt.Errorf("unable to get installation for instance: %w", err)
		}
	}
	if installation.DeletionTimestamp.IsZero() {
		if err := c.Client().Delete(ctx, installation); err != nil {
			return false, fmt.Errorf("unable to delete installation for instance: %w", err)
		}
	}
	return false, nil
}
func ( c * Controller ) ensureDeleteInstallationForInstance ( ctx context . Context , log logr . Logger , instance * lssv1alpha1 . Instance ) ( bool , error ) { log . Info ( " " ) installation := & lsv1alpha1 . Installation { } if err := c . Client ( ) . Get ( ctx , instance . Status . InstallationRef . NamespacedName ( ) , installation ) ; err != nil { if apierrors . IsNotFound ( err ) { instance . Status . InstallationRef = nil if err := c . Client ( ) . Status ( ) . Update ( ctx , instance ) ; err != nil { return false , fmt . Errorf ( " " , err ) } return true , nil } else { return false , fmt . Errorf ( " " , err ) } } if installation . DeletionTimestamp . IsZero ( ) { if err := c . Client ( ) . Delete ( ctx , installation ) ; err != nil { return false , fmt . Errorf ( " " , err ) } } return false , nil }
ensureDeleteInstallationForInstance ensures that the installation for an instance is deleted
ensureDeleteInstallationForInstance ensures that the installation for an instance is deleted