Fix getting exposure strategy in case of k8s (#766)

* Fix getting exposure strategy in case of k8s

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
pull/767/head
Anatolii Bazko 2021-04-09 10:33:15 +03:00 committed by GitHub
parent 236f7ab5de
commit 268899efa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 5 deletions

View File

@ -994,7 +994,7 @@ func getDefaultCheHost(deployContext *deploy.DeployContext) (string, error) {
}
func getServerExposingServiceName(cr *orgv1.CheCluster) string {
if util.GetValue(cr.Spec.Server.ServerExposureStrategy, deploy.DefaultServerExposureStrategy) == "single-host" && deploy.GetSingleHostExposureType(cr) == "gateway" {
if util.GetServerExposureStrategy(cr) == "single-host" && deploy.GetSingleHostExposureType(cr) == "gateway" {
return gateway.GatewayServiceName
}
return deploy.CheServiceName

View File

@ -28,7 +28,7 @@ func Expose(
routeCustomSettings orgv1.RouteCustomSettings,
ingressCustomSettings orgv1.IngressCustomSettings,
component string) (endpont string, done bool, err error) {
exposureStrategy := util.GetValue(deployContext.CheCluster.Spec.Server.ServerExposureStrategy, deploy.DefaultServerExposureStrategy)
exposureStrategy := util.GetServerExposureStrategy(deployContext.CheCluster)
var domain string
var endpoint string
var pathPrefix string

View File

@ -54,7 +54,7 @@ var (
// SyncGatewayToCluster installs or deletes the gateway based on the custom resource configuration
func SyncGatewayToCluster(deployContext *deploy.DeployContext) error {
if util.GetValue(deployContext.CheCluster.Spec.Server.ServerExposureStrategy, deploy.DefaultServerExposureStrategy) == "single-host" &&
if util.GetServerExposureStrategy(deployContext.CheCluster) == "single-host" &&
(deploy.GetSingleHostExposureType(deployContext.CheCluster) == "gateway") {
return syncAll(deployContext)
}

View File

@ -55,7 +55,7 @@ func GetIngressSpec(
component string) *v1beta1.Ingress {
tlsSupport := deployContext.CheCluster.Spec.Server.TlsSupport
ingressStrategy := util.GetValue(deployContext.CheCluster.Spec.Server.ServerExposureStrategy, DefaultServerExposureStrategy)
ingressStrategy := util.GetServerExposureStrategy(deployContext.CheCluster)
ingressDomain := deployContext.CheCluster.Spec.K8s.IngressDomain
ingressClass := util.GetValue(deployContext.CheCluster.Spec.K8s.IngressClass, DefaultIngressClass)
labels := GetLabels(deployContext.CheCluster, component)

View File

@ -158,7 +158,7 @@ func GetCheConfigMapData(deployContext *deploy.DeployContext) (cheEnv map[string
chePostgresDb := util.GetValue(deployContext.CheCluster.Spec.Database.ChePostgresDb, deploy.DefaultChePostgresDb)
keycloakRealm := util.GetValue(deployContext.CheCluster.Spec.Auth.IdentityProviderRealm, cheFlavor)
keycloakClientId := util.GetValue(deployContext.CheCluster.Spec.Auth.IdentityProviderClientId, cheFlavor+"-public")
ingressStrategy := util.GetValue(deployContext.CheCluster.Spec.Server.ServerExposureStrategy, deploy.DefaultServerExposureStrategy)
ingressStrategy := util.GetServerExposureStrategy(deployContext.CheCluster)
ingressClass := util.GetValue(deployContext.CheCluster.Spec.K8s.IngressClass, deploy.DefaultIngressClass)
devfileRegistryURL := deployContext.CheCluster.Status.DevfileRegistryURL
pluginRegistryURL := deployContext.CheCluster.Status.PluginRegistryURL

View File

@ -482,6 +482,26 @@ func TestShouldSetUpCorrectlyInternalDevfileRegistryServiceURL(t *testing.T) {
"CHE_WORKSPACE_DEVFILE__REGISTRY__INTERNAL__URL": "http://devfile-registry.eclipse-che.svc:8080",
},
},
{
name: "Kubernetes strategy should be set correctly",
cheCluster: &orgv1.CheCluster{
TypeMeta: metav1.TypeMeta{
Kind: "CheCluster",
APIVersion: "org.eclipse.che/v1",
},
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
},
Spec: orgv1.CheClusterSpec{
K8s: orgv1.CheClusterSpecK8SOnly{
IngressStrategy: "single-host",
},
},
},
expectedData: map[string]string{
"CHE_INFRA_KUBERNETES_SERVER__STRATEGY": "single-host",
},
},
}
for _, testCase := range testCases {