Skip to content

Commit

Permalink
Fix broken IngressRoute no-TLS replication (#23)
Browse files Browse the repository at this point in the history
shortcircuit if TLS is nil
  • Loading branch information
alehechka authored Jul 29, 2023
1 parent 8467a2f commit c03a137
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions client/replicate/traefik/ingressroute/ingressroutes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c03a137

Please sign in to comment.