diff --git a/client/replicate/traefik/ingressroute/ingressroutes.go b/client/replicate/traefik/ingressroute/ingressroutes.go index bb24d6b..8001716 100644 --- a/client/replicate/traefik/ingressroute/ingressroutes.go +++ b/client/replicate/traefik/ingressroute/ingressroutes.go @@ -162,39 +162,37 @@ func (r *Replicator) prepareRoutes(namespace string, source *v1alpha1.IngressRou } func (r *Replicator) prepareTLS(namespace string, source *v1alpha1.IngressRoute) *v1alpha1.TLS { + if source.Spec.TLS == nil { + return nil + } + annotations := source.GetAnnotations() + tls := &v1alpha1.TLS{ + SecretName: annotations[common.TLDSecretName], + Options: source.Spec.TLS.Options, + Store: source.Spec.TLS.Store, + CertResolver: source.Spec.TLS.CertResolver, + } + if tld, ok := annotations[common.TopLevelDomain]; ok { - return &v1alpha1.TLS{ - SecretName: annotations[common.TLDSecretName], - Options: source.Spec.TLS.Options, - Store: source.Spec.TLS.Store, - CertResolver: source.Spec.TLS.CertResolver, - Domains: []types.Domain{{ - Main: common.PrepareTLD(namespace, tld), - }}, - } + tls.Domains = []types.Domain{{ + Main: common.PrepareTLD(namespace, tld), + }} + + return tls } if r.HasDefaultIngressHostname() { - return &v1alpha1.TLS{ - SecretName: annotations[common.TLDSecretName], - Options: source.Spec.TLS.Options, - Store: source.Spec.TLS.Store, - CertResolver: source.Spec.TLS.CertResolver, - Domains: []types.Domain{{ - Main: common.PrepareTLD(namespace, r.DefaultIngressHostname), - }}, - } - } + tls.Domains = []types.Domain{{ + Main: common.PrepareTLD(namespace, r.DefaultIngressHostname), + }} - return &v1alpha1.TLS{ - SecretName: source.Spec.TLS.SecretName, - Options: source.Spec.TLS.Options, - Store: source.Spec.TLS.Store, - CertResolver: source.Spec.TLS.CertResolver, - Domains: prepareDomains(namespace, source), + return tls } + + tls.Domains = prepareDomains(namespace, source) + return tls } func prepareDomains(namespace string, source *v1alpha1.IngressRoute) (domains []types.Domain) {