diff --git a/pkg/controller/che/che_controller.go b/pkg/controller/che/che_controller.go index fd3751878..578a29649 100644 --- a/pkg/controller/che/che_controller.go +++ b/pkg/controller/che/che_controller.go @@ -255,6 +255,14 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e logrus.Errorf("An error occurred when detecting current infra: %s", err) } + // Check Che CR correctness + if err := ValidateCheCR(instance, isOpenShift); err != nil { + // Che cannot be deployed with current configuration. + // Print error message in logs and wait until the configuration is changed. + logrus.Error(err) + return reconcile.Result{}, nil + } + if isOpenShift { // delete oAuthClient before CR is deleted doInstallOpenShiftoAuthProvider := instance.Spec.Auth.OpenShiftoAuth diff --git a/pkg/controller/che/che_cr_validator.go b/pkg/controller/che/che_cr_validator.go new file mode 100644 index 000000000..fa33834f4 --- /dev/null +++ b/pkg/controller/che/che_cr_validator.go @@ -0,0 +1,33 @@ +// +// Copyright (c) 2012-2019 Red Hat, Inc. +// This program and the accompanying materials are made +// available under the terms of the Eclipse Public License 2.0 +// which is available at https://www.eclipse.org/legal/epl-2.0/ +// +// SPDX-License-Identifier: EPL-2.0 +// +// Contributors: +// Red Hat, Inc. - initial API and implementation +// +package che + +import ( + "fmt" + + orgv1 "github.com/eclipse/che-operator/pkg/apis/org/v1" +) + +// ValidateCheCR checks Che CR configuration. +// It should detect: +// - configurations which miss required field(s) to deploy Che +// - self-contradictory configurations +// - configurations with which it is impossible to deploy Che +func ValidateCheCR(checluster *orgv1.CheCluster, isOpenshift bool) error { + if !isOpenshift { + if checluster.Spec.K8s.IngressDomain == "" { + return fmt.Errorf("Required field \"spec.K8s.IngressDomain\" is not set") + } + } + + return nil +}