// createOrUpdateIngress check if the ingress already exists, if not create a new one, if yes update it
createOrUpdateIngress check if the ingress already exists, if not create a new one, if yes update it
// createOrUpdateIngress check if the ingress already exists if not create a new one if yes update it
func (r *ReconcileIntegration) createOrUpdateIngress(config *EIConfigNew) error {
	autoCreateIngressInfo := config.integrationConfigMap.Data[autoIngressCreationKey]
	autoCreateIngress, err := strconv.ParseBool(autoCreateIngressInfo)
	if err != nil {
		log.Error(err, "Cannot parse autoIngressCreationKey to a boolean value. Setting false")
		autoCreateIngress = false
	}
	if autoCreateIngress {
		ingress := &networking.Ingress{}
		var integration = config.integration
		namespace := types.NamespacedName{Name: nameForIngress(), Namespace: integration.Namespace}
		err := k8s.Get(&r.client, namespace, ingress)
		if err != nil {
			if errors.IsNotFound(err) {		
				eiIngress := r.ingressForIntegration(config)
				err = k8s.Apply(&r.client, eiIngress)
				if err != nil {
					return err
				}
			} else {
				log.Error(err, "Failed to get Ingress")
				return err
			}
		} else {		
			_, ruleExists := CheckIngressRulesExist(config, ingress)
			if !ruleExists {
				eiIngress := r.updateIngressForIntegration(config, ingress)
				log.Info("Updating a new Ingress", "Ingress.Namespace", integration.Namespace,
					"Ingress.Name", nameForIngress())
				err = r.client.Update(context.TODO(), eiIngress)
				if err != nil {
					log.Error(err, "Failed to updated new Ingress", "Ingress.Namespace",
						integration.Namespace, "Ingress.Name", nameForIngress())
					return err
				}
			}
		}
	}
	return nil
}
func ( r * ReconcileIntegration ) createOrUpdateIngress ( config * EIConfigNew ) error { autoCreateIngressInfo := config . integrationConfigMap . Data [ autoIngressCreationKey ] autoCreateIngress , err := strconv . ParseBool ( autoCreateIngressInfo ) if err != nil { log . Error ( err , " " ) autoCreateIngress = false } if autoCreateIngress { ingress := & networking . Ingress { } var integration = config . integration namespace := types . NamespacedName { Name : nameForIngress ( ) , Namespace : integration . Namespace } err := k8s . Get ( & r . client , namespace , ingress ) if err != nil { if errors . IsNotFound ( err ) { eiIngress := r . ingressForIntegration ( config ) err = k8s . Apply ( & r . client , eiIngress ) if err != nil { return err } } else { log . Error ( err , " " ) return err } } else { _ , ruleExists := CheckIngressRulesExist ( config , ingress ) if ! ruleExists { eiIngress := r . updateIngressForIntegration ( config , ingress ) log . Info ( " " , " " , integration . Namespace , " " , nameForIngress ( ) ) err = r . client . Update ( context . TODO ( ) , eiIngress ) if err != nil { log . Error ( err , " " , " " , integration . Namespace , " " , nameForIngress ( ) ) return err } } } } return nil }
createOrUpdateIngress check if the ingress already exists, if not create a new one, if yes update it
createOrUpdateIngress check if the ingress already exists if not create a new one if yes update it
// No ingress found, define a new Ingress //  ingress already exists, check and update the rules