// Reconcile reconciles requests for landscaperdeployments
Reconcile reconciles requests for landscaperdeployments
// Reconcile reconciles requests for landscaperdeployments
func (c *Controller) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) {
	log := c.Log().WithValues("landscaperdeployment", req.NamespacedName.String())
	ctx = logr.NewContext(ctx, log)
	log.V(5).Info("reconcile", "resource", req.NamespacedName)
	deployment := &lssv1alpha1.LandscaperDeployment{}
	if err := c.Client().Get(ctx, req.NamespacedName, deployment); err != nil {
		if apierrors.IsNotFound(err) {
			c.Log().V(5).Info(err.Error())
			return reconcile.Result{}, nil
		}
		return reconcile.Result{}, err
	}
	c.Operation.Scheme().Default(deployment)
	errHdl := handleErrorFunc(log, c.Client(), deployment)
	if deployment.Status.ObservedGeneration < deployment.GetGeneration() {
		deployment.Status.ObservedGeneration = deployment.GetGeneration()
		if err := c.Client().Status().Update(ctx, deployment); err != nil {
			return reconcile.Result{}, err
		}
	}
	if deployment.DeletionTimestamp.IsZero() && !kutils.HasFinalizer(deployment, lssv1alpha1.LandscaperServiceFinalizer) {
		controllerutil.AddFinalizer(deployment, lssv1alpha1.LandscaperServiceFinalizer)
		if err := c.Client().Update(ctx, deployment); err != nil {
			return reconcile.Result{}, err
		}
		return reconcile.Result{}, nil
	}
	if !deployment.DeletionTimestamp.IsZero() {
		return reconcile.Result{}, errHdl(ctx, c.handleDelete(ctx, log, deployment))
	}
	return reconcile.Result{}, errHdl(ctx, c.reconcile(ctx, log, deployment))
}
func ( c * Controller ) Reconcile ( ctx context . Context , req reconcile . Request ) ( reconcile . Result , error ) { log := c . Log ( ) . WithValues ( " " , req . NamespacedName . String ( ) ) ctx = logr . NewContext ( ctx , log ) log . V ( 5 ) . Info ( " " , " " , req . NamespacedName ) deployment := & lssv1alpha1 . LandscaperDeployment { } if err := c . Client ( ) . Get ( ctx , req . NamespacedName , deployment ) ; err != nil { if apierrors . IsNotFound ( err ) { c . Log ( ) . V ( 5 ) . Info ( err . Error ( ) ) return reconcile . Result { } , nil } return reconcile . Result { } , err } c . Operation . Scheme ( ) . Default ( deployment ) errHdl := handleErrorFunc ( log , c . Client ( ) , deployment ) if deployment . Status . ObservedGeneration < deployment . GetGeneration ( ) { deployment . Status . ObservedGeneration = deployment . GetGeneration ( ) if err := c . Client ( ) . Status ( ) . Update ( ctx , deployment ) ; err != nil { return reconcile . Result { } , err } } if deployment . DeletionTimestamp . IsZero ( ) && ! kutils . HasFinalizer ( deployment , lssv1alpha1 . LandscaperServiceFinalizer ) { controllerutil . AddFinalizer ( deployment , lssv1alpha1 . LandscaperServiceFinalizer ) if err := c . Client ( ) . Update ( ctx , deployment ) ; err != nil { return reconcile . Result { } , err } return reconcile . Result { } , nil } if ! deployment . DeletionTimestamp . IsZero ( ) { return reconcile . Result { } , errHdl ( ctx , c . handleDelete ( ctx , log , deployment ) ) } return reconcile . Result { } , errHdl ( ctx , c . reconcile ( ctx , log , deployment ) ) }
Reconcile reconciles requests for landscaperdeployments
Reconcile reconciles requests for landscaperdeployments
// update observed generation // set finalizer // reconcile delete // reconcile