From 8e188216d12b4198e7659f7800fccfef631db013 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 24 Jan 2026 05:40:27 +0100 Subject: [PATCH] refactor: move willingToSleep --- cmd/cmd_renew.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/cmd_renew.go b/cmd/cmd_renew.go index 198030b97..78ddcd504 100644 --- a/cmd/cmd_renew.go +++ b/cmd/cmd_renew.go @@ -111,7 +111,9 @@ func renewForDomains(ctx context.Context, cmd *cli.Command, account *storage.Acc if !cmd.Bool(flgARIDisable) { client = setupClient(cmd, account, keyType) - ariRenewalTime = getARIRenewalTime(ctx, cmd, cert, domain, client) + willingToSleep := cmd.Duration(flgARIWaitToRenewDuration) + + ariRenewalTime = getARIRenewalTime(ctx, willingToSleep, cert, domain, client) if ariRenewalTime != nil { now := time.Now().UTC() @@ -255,7 +257,9 @@ func renewForCSR(ctx context.Context, cmd *cli.Command, account *storage.Account if !cmd.Bool(flgARIDisable) { client = setupClient(cmd, account, keyType) - ariRenewalTime = getARIRenewalTime(ctx, cmd, cert, domain, client) + willingToSleep := cmd.Duration(flgARIWaitToRenewDuration) + + ariRenewalTime = getARIRenewalTime(ctx, willingToSleep, cert, domain, client) if ariRenewalTime != nil { now := time.Now().UTC() @@ -364,7 +368,7 @@ func needRenewalDynamic(x509Cert *x509.Certificate, domain string, now time.Time } // getARIRenewalTime checks if the certificate needs to be renewed using the renewalInfo endpoint. -func getARIRenewalTime(ctx context.Context, cmd *cli.Command, cert *x509.Certificate, domain string, client *lego.Client) *time.Time { +func getARIRenewalTime(ctx context.Context, willingToSleep time.Duration, cert *x509.Certificate, domain string, client *lego.Client) *time.Time { if cert.IsCA { log.Fatal("Certificate bundle starts with a CA certificate.", log.DomainAttr(domain)) } @@ -390,7 +394,7 @@ func getARIRenewalTime(ctx context.Context, cmd *cli.Command, cert *x509.Certifi now := time.Now().UTC() - renewalTime := renewalInfo.ShouldRenewAt(now, cmd.Duration(flgARIWaitToRenewDuration)) + renewalTime := renewalInfo.ShouldRenewAt(now, willingToSleep) if renewalTime == nil { log.Info("acme: renewalInfo endpoint indicates that renewal is not needed.", log.DomainAttr(domain)) return nil