// Reconcile reads that state of the cluster for a Integration object and makes changes based on the state read
// and what is in the Integration.Spec
// Note: The Controller will requeue the Request to be processed again if the returned error is non-nil or
// Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
Reconcile reads that state of the cluster for a Integration object and makes changes based on the state read
and what is in the Integration.Spec
Note: The Controller will requeue the Request to be processed again if the returned error is non-nil or
Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
// Reconcile reads that state of the cluster for a Integration object and makes changes based on the state read // and what is in the Integration . Spec // Note : The Controller will requeue the Request to be processed again if the returned error is non - nil or // Result . Requeue is true otherwise upon completion it will remove the work from the queue .
func (r *ReconcileIntegration) Reconcile(request reconcile.Request) (reconcile.Result, error) {
	reqLogger := log.WithValues("Request.Namespace", request.Namespace, "Request.Name", request.Name)
	integration := &wso2v1alpha2.Integration{}
	err := r.client.Get(context.TODO(), request.NamespacedName, integration)
	if err != nil {
		if errors.IsNotFound(err) {
			return reconcile.Result{}, nil
		}
		reqLogger.Error(err, "Error fetching the integration object.")
		return reconcile.Result{}, err
	}
	eiConfig, configErr := r.PopulateConfigurations(integration)
	if configErr != nil {return reconcile.Result{}, err}
	deploymentObj, err := r.createOrUpdateDeployment(eiConfig)
	if err != nil {
		reqLogger.Error(err, "Failed to create or update the deployment.",
			"Deployment.Namespace", eiConfig.integration.Namespace,
			"Deployment.Name", eiConfig.integration.Name)
		return reconcile.Result{}, err
	}
	err = r.createOrUpdateHPA(eiConfig)
	if err != nil {
		reqLogger.Info("Failed to create/update HPA for the deployment.",
			"Integration.Namespace", integration.Namespace, "Integration.Name", integration.Name)
		return reconcile.Result{}, err
	}
	err = r.createOrUpdateService(eiConfig)
	if err != nil {
		reqLogger.Info("Failed to create/update service for the deployment",
			"Integration.Namespace", integration.Namespace, "Integration.Name", integration.Name)
		return reconcile.Result{}, err
	}
	err = r.createOrUpdateIngress(&eiConfig)
	if err != nil {
		reqLogger.Info("Failed to create/update ingress for the deployment",
			"Integration.Namespace", integration.Namespace, "Integration.Name", integration.Name)
		return reconcile.Result{}, err
	}
	err = r.updateStatus(deploymentObj, eiConfig)
	if err != nil {
		reqLogger.Error(err, "Failed to update Integration status")
		return reconcile.Result{}, err
	}
	var reconcileIntervalAsStr = eiConfig.integrationConfigMap.Data[reconcileIntervalKey]
	var reconcileInterval, convErr = strconv.Atoi(reconcileIntervalAsStr)
	if convErr != nil {
		reconcileInterval = 10
	}
	return reconcile.Result{ RequeueAfter: time.Duration(reconcileInterval) * time.Second, Requeue: true}, nil
}
func ( r * ReconcileIntegration ) Reconcile ( request reconcile . Request ) ( reconcile . Result , error ) { reqLogger := log . WithValues ( " " , request . Namespace , " " , request . Name ) integration := & wso2v1alpha2 . Integration { } err := r . client . Get ( context . TODO ( ) , request . NamespacedName , integration ) if err != nil { if errors . IsNotFound ( err ) { return reconcile . Result { } , nil } reqLogger . Error ( err , " " ) return reconcile . Result { } , err } eiConfig , configErr := r . PopulateConfigurations ( integration ) if configErr != nil { return reconcile . Result { } , err } deploymentObj , err := r . createOrUpdateDeployment ( eiConfig ) if err != nil { reqLogger . Error ( err , " " , " " , eiConfig . integration . Namespace , " " , eiConfig . integration . Name ) return reconcile . Result { } , err } err = r . createOrUpdateHPA ( eiConfig ) if err != nil { reqLogger . Info ( " " , " " , integration . Namespace , " " , integration . Name ) return reconcile . Result { } , err } err = r . createOrUpdateService ( eiConfig ) if err != nil { reqLogger . Info ( " " , " " , integration . Namespace , " " , integration . Name ) return reconcile . Result { } , err } err = r . createOrUpdateIngress ( & eiConfig ) if err != nil { reqLogger . Info ( " " , " " , integration . Namespace , " " , integration . Name ) return reconcile . Result { } , err } err = r . updateStatus ( deploymentObj , eiConfig ) if err != nil { reqLogger . Error ( err , " " ) return reconcile . Result { } , err } var reconcileIntervalAsStr = eiConfig . integrationConfigMap . Data [ reconcileIntervalKey ] var reconcileInterval , convErr = strconv . Atoi ( reconcileIntervalAsStr ) if convErr != nil { reconcileInterval = 10 } return reconcile . Result { RequeueAfter : time . Duration ( reconcileInterval ) * time . Second , Requeue : true } , nil }
Reconcile reads that state of the cluster for a Integration object and makes changes based on the state read
and what is in the Integration.Spec
Note: The Controller will requeue the Request to be processed again if the returned error is non-nil or
Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
Reconcile reads that state of the cluster for a Integration object and makes changes based on the state read and what is in the Integration . Spec Note : The Controller will requeue the Request to be processed again if the returned error is non - nil or Result . Requeue is true otherwise upon completion it will remove the work from the queue .
// Fetch the Integration integration // Request object not found, could have been deleted after reconcile request. // Owned objects are automatically garbage collected. For additional cleanup logic use finalizers. // Return and don't requeue // Error reading the object - requeue the request. //populate configurations //create or update the deployment //create or update ingress //update status //set to reconcile again after configured interval