// Reconcile reconciles requests for servicetargetconfigs
Reconcile reconciles requests for servicetargetconfigs
// Reconcile reconciles requests for servicetargetconfigs
func (c *Controller) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) {
	log := c.Log().WithValues("servicetargetconfig", req.NamespacedName.String())
	ctx = logr.NewContext(ctx, log)
	log.V(5).Info("reconcile", "resource", req.NamespacedName)
	config := &lssv1alpha1.ServiceTargetConfig{}
	if err := c.Client().Get(ctx, req.NamespacedName, config); 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(config)
	if config.Status.ObservedGeneration < config.GetGeneration() {
		config.Status.ObservedGeneration = config.GetGeneration()
		if err := c.Client().Status().Update(ctx, config); err != nil {
			return reconcile.Result{}, err
		}
	}
	if config.DeletionTimestamp.IsZero() && !kutils.HasFinalizer(config, lssv1alpha1.LandscaperServiceFinalizer) {
		controllerutil.AddFinalizer(config, lssv1alpha1.LandscaperServiceFinalizer)
		if err := c.Client().Update(ctx, config); err != nil {
			return reconcile.Result{}, err
		}
		return reconcile.Result{}, nil
	}
	if !config.DeletionTimestamp.IsZero() {
		controllerutil.RemoveFinalizer(config, lssv1alpha1.LandscaperServiceFinalizer)
		if err := c.Client().Update(ctx, config); err != nil {
			return reconcile.Result{}, err
		}
	}
	return reconcile.Result{}, c.reconcile(ctx, log, config)
}
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 ) config := & lssv1alpha1 . ServiceTargetConfig { } if err := c . Client ( ) . Get ( ctx , req . NamespacedName , config ) ; 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 ( config ) if config . Status . ObservedGeneration < config . GetGeneration ( ) { config . Status . ObservedGeneration = config . GetGeneration ( ) if err := c . Client ( ) . Status ( ) . Update ( ctx , config ) ; err != nil { return reconcile . Result { } , err } } if config . DeletionTimestamp . IsZero ( ) && ! kutils . HasFinalizer ( config , lssv1alpha1 . LandscaperServiceFinalizer ) { controllerutil . AddFinalizer ( config , lssv1alpha1 . LandscaperServiceFinalizer ) if err := c . Client ( ) . Update ( ctx , config ) ; err != nil { return reconcile . Result { } , err } return reconcile . Result { } , nil } if ! config . DeletionTimestamp . IsZero ( ) { controllerutil . RemoveFinalizer ( config , lssv1alpha1 . LandscaperServiceFinalizer ) if err := c . Client ( ) . Update ( ctx , config ) ; err != nil { return reconcile . Result { } , err } } return reconcile . Result { } , c . reconcile ( ctx , log , config ) }
Reconcile reconciles requests for servicetargetconfigs
Reconcile reconciles requests for servicetargetconfigs
// update observed generation // set finalizer // TODO: handle delete