Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to default Che secret name if none is given in case of turned on tls #191

Merged
merged 1 commit into from
Mar 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pkg/deploy/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
package deploy

import (
"strconv"

orgv1 "github.com/eclipse/che-operator/pkg/apis/org/v1"
"github.com/eclipse/che-operator/pkg/util"
"k8s.io/api/extensions/v1beta1"
Expand All @@ -28,11 +30,18 @@ func NewIngress(cr *orgv1.CheCluster, name string, serviceName string, port int)
ingressDomain := cr.Spec.K8s.IngressDomain
ingressClass := util.GetValue(cr.Spec.K8s.IngressClass, DefaultIngressClass)
labels := GetLabels(cr, name)
tlsSecretName := cr.Spec.K8s.TlsSecretName

tls := "false"
if tlsSupport {
tls = "true"
}
tlsSecretName := cr.Spec.K8s.TlsSecretName
// If TLS is turned on but the secret is not set, try to use Che default value as k8s cluster defaults will not work.
tlsFlag, _ := strconv.ParseBool(tls)
if tlsFlag && tlsSecretName == "" {
Copy link
Contributor

@AndrienkoAleksandr AndrienkoAleksandr Mar 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also use util.GetValue(stringFromCR, defaultStringValue)

Than code could be:

tlsSecretName := cr.Spec.K8s.TlsSecretName
tlsFlag, _ := strconv.ParseBool(tls)
if tlsFlag {
        tlsSecretName = util.getValue(tlsSecretName, "che-tls")
}

But it's optional, up to you.

tlsSecretName = "che-tls"
}

host := ""
path := "/"
if name == "keycloak" && ingressStrategy != "multi-host" {
Expand Down