Fix import and error management
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -17,6 +17,7 @@ package certmanager
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -79,9 +80,6 @@ func (p *Provisioner) Run(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Provisioner) checkDNSConfiguration(domain string) error {
|
func (p *Provisioner) checkDNSConfiguration(domain string) error {
|
||||||
if p.cnameTarget == "" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
cnameRecords, err := net.LookupCNAME(domain)
|
cnameRecords, err := net.LookupCNAME(domain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("DNS lookup Failed: %w", err)
|
return fmt.Errorf("DNS lookup Failed: %w", err)
|
||||||
@@ -91,12 +89,13 @@ func (p *Provisioner) checkDNSConfiguration(domain string) error {
|
|||||||
|
|
||||||
if !strings.EqualFold(actualTarget, expectedTarget) {
|
if !strings.EqualFold(actualTarget, expectedTarget) {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
"DNS configuration mismatch: domain %q resolves to %q, expected %q",
|
"cname target mismatch: domain %q resolves to %q, expected %q",
|
||||||
domain,
|
domain,
|
||||||
actualTarget,
|
actualTarget,
|
||||||
expectedTarget,
|
p.cnameTarget,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,11 +235,12 @@ func (p *Provisioner) provisionDomainCertificate(
|
|||||||
if err := p.checkDNSConfiguration(domain.Domain); err != nil {
|
if err := p.checkDNSConfiguration(domain.Domain); err != nil {
|
||||||
p.logger.WarnCtx(
|
p.logger.WarnCtx(
|
||||||
ctx,
|
ctx,
|
||||||
"DNS configuration check failed, skipping ACME challenge",
|
"dns configuration check failed",
|
||||||
log.String("domain", domain.Domain),
|
log.String("domain", domain.Domain),
|
||||||
log.Error(err),
|
log.Error(err),
|
||||||
)
|
)
|
||||||
return fmt.Errorf("DNS configuration not ready: %w", err)
|
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
p.logger.InfoCtx(ctx, "DNS configuration verified, initiating HTTP challenge for domain", log.String("domain", domain.Domain))
|
p.logger.InfoCtx(ctx, "DNS configuration verified, initiating HTTP challenge for domain", log.String("domain", domain.Domain))
|
||||||
|
|||||||
Reference in New Issue
Block a user