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

ZeroSSLIssuer: Make PollInterval configurable #316

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
15 changes: 13 additions & 2 deletions zerosslissuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ type ZeroSSLIssuer struct {
// validation, set this field.
CNAMEValidation *DNSManager

// Delay between poll attempts.
PollInterval time.Duration

// An optional (but highly recommended) logger.
Logger *zap.Logger
}
Expand Down Expand Up @@ -203,8 +206,8 @@ func (iss *ZeroSSLIssuer) Issue(ctx context.Context, csr *x509.CertificateReques
}, nil
}

func (*ZeroSSLIssuer) waitForCertToBeIssued(ctx context.Context, client zerossl.Client, cert zerossl.CertificateObject) (zerossl.CertificateObject, error) {
ticker := time.NewTicker(5 * time.Second)
func (iss *ZeroSSLIssuer) waitForCertToBeIssued(ctx context.Context, client zerossl.Client, cert zerossl.CertificateObject) (zerossl.CertificateObject, error) {
ticker := time.NewTicker(iss.pollInterval())
defer ticker.Stop()

for {
Expand All @@ -227,6 +230,13 @@ func (*ZeroSSLIssuer) waitForCertToBeIssued(ctx context.Context, client zerossl.
}
}

func (iss *ZeroSSLIssuer) pollInterval() time.Duration {
if iss.PollInterval == 0 {
return defaultPollInterval
}
return iss.PollInterval
}

func (iss *ZeroSSLIssuer) getClient() zerossl.Client {
return zerossl.Client{AccessKey: iss.APIKey}
}
Expand Down Expand Up @@ -302,6 +312,7 @@ const (
zerosslAPIBase = "https://" + zerossl.BaseURL + "/acme"
zerosslValidationPathPrefix = "/.well-known/pki-validation/"
zerosslIssuerKey = "zerossl"
defaultPollInterval = 5 * time.Second
)

// Interface guards
Expand Down
Loading