Skip to content

Commit

Permalink
Merge pull request #111 from SgtCoDFish/renew-before-tweak
Browse files Browse the repository at this point in the history
Don't set renew-before if value parses to zero
  • Loading branch information
cert-manager-prow[bot] authored Oct 18, 2024
2 parents 0da68ae + fa97d40 commit 2d0ee6d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/controller/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,16 @@ func (r *RouteController) buildNextCert(ctx context.Context, route *routev1.Rout
return nil, fmt.Errorf("invalid duration annotation on Route %s/%s", route.Namespace, route.Name)
}

var renewBefore time.Duration
var renewBefore *metav1.Duration
if metav1.HasAnnotation(route.ObjectMeta, cmapi.RenewBeforeAnnotationKey) {
renewBeforeAnnotation := route.Annotations[cmapi.RenewBeforeAnnotationKey]

var err error
renewBefore, err = time.ParseDuration(renewBeforeAnnotation)
parsedRenewBefore, err := time.ParseDuration(renewBeforeAnnotation)
if err != nil {
return nil, fmt.Errorf("invalid renew-before annotation %q on Route %s/%s", renewBeforeAnnotation, route.Namespace, route.Name)
}

renewBefore = &metav1.Duration{Duration: parsedRenewBefore}
}

var privateKeyAlgorithm cmapi.PrivateKeyAlgorithm
Expand Down Expand Up @@ -494,7 +495,7 @@ func (r *RouteController) buildNextCert(ctx context.Context, route *routev1.Rout
Spec: cmapi.CertificateSpec{
SecretName: secretName,
Duration: &metav1.Duration{Duration: duration},
RenewBefore: &metav1.Duration{Duration: renewBefore},
RenewBefore: renewBefore,
RevisionHistoryLimit: revisionHistoryLimit,
CommonName: route.Annotations[cmapi.CommonNameAnnotationKey],
Subject: &cmapi.X509Subject{
Expand Down

0 comments on commit 2d0ee6d

Please sign in to comment.