diff --git a/cmd/ingress-shim/controller/sync.go b/cmd/ingress-shim/controller/sync.go index 7a4bf822a..0b7794226 100644 --- a/cmd/ingress-shim/controller/sync.go +++ b/cmd/ingress-shim/controller/sync.go @@ -188,14 +188,15 @@ func (c *Controller) setIssuerSpecificConfig(crt *v1alpha1.Certificate, issuer v } switch challengeType { case "http01": + domainCfg.HTTP01 = &v1alpha1.ACMECertificateHTTP01Config{} editInPlace, ok := ingAnnotations[editInPlaceAnnotation] // If annotation isn't present, or it's set to true, edit the existing ingress if ok && editInPlace == "true" { - domainCfg.HTTP01 = &v1alpha1.ACMECertificateHTTP01Config{Ingress: ing.Name} + domainCfg.HTTP01.Ingress = ing.Name } else { ingressClass, ok := ingAnnotations[ingressClassAnnotation] if ok { - domainCfg.HTTP01 = &v1alpha1.ACMECertificateHTTP01Config{IngressClass: &ingressClass} + domainCfg.HTTP01.IngressClass = &ingressClass } } case "dns01": diff --git a/cmd/ingress-shim/controller/sync_test.go b/cmd/ingress-shim/controller/sync_test.go index c208c968a..a23b2ce35 100644 --- a/cmd/ingress-shim/controller/sync_test.go +++ b/cmd/ingress-shim/controller/sync_test.go @@ -129,6 +129,55 @@ func TestBuildCertificates(t *testing.T) { }, }, }, + { + Name: "return a single HTTP01 Certificate for an ingress with a single valid TLS entry and HTTP01 annotations with no ingress class set", + Ingress: &extv1beta1.Ingress{ + ObjectMeta: metav1.ObjectMeta{ + Name: "ingress-name", + Namespace: "ingress-namespace", + Annotations: map[string]string{ + clusterIssuerNameAnnotation: "issuer-name", + acmeIssuerChallengeTypeAnnotation: "http01", + }, + }, + Spec: extv1beta1.IngressSpec{ + TLS: []extv1beta1.IngressTLS{ + { + Hosts: []string{"example.com", "www.example.com"}, + SecretName: "example-com-tls", + }, + }, + }, + }, + ClusterIssuerLister: []*v1alpha1.ClusterIssuer{buildACMEClusterIssuer("issuer-name")}, + ExpectedCreate: []*v1alpha1.Certificate{ + { + ObjectMeta: metav1.ObjectMeta{ + Name: "example-com-tls", + Namespace: "ingress-namespace", + OwnerReferences: []metav1.OwnerReference{*metav1.NewControllerRef(buildIngress("ingress-name", "ingress-namespace", nil), ingressGVK)}, + }, + Spec: v1alpha1.CertificateSpec{ + DNSNames: []string{"example.com", "www.example.com"}, + SecretName: "example-com-tls", + IssuerRef: v1alpha1.ObjectReference{ + Name: "issuer-name", + Kind: "ClusterIssuer", + }, + ACME: &v1alpha1.ACMECertificateConfig{ + Config: []v1alpha1.ACMECertificateDomainConfig{ + { + Domains: []string{"example.com", "www.example.com"}, + ACMESolverConfig: v1alpha1.ACMESolverConfig{ + HTTP01: &v1alpha1.ACMECertificateHTTP01Config{}, + }, + }, + }, + }, + }, + }, + }, + }, { Name: "return a single HTTP01 Certificate for an ingress with a single valid TLS entry and HTTP01 annotations with a custom ingress class", Ingress: &extv1beta1.Ingress{