Skip to content

Commit

Permalink
change renew-before to a pointer so it's not set unconditionally
Browse files Browse the repository at this point in the history
Signed-off-by: Ashley Davis <[email protected]>
  • Loading branch information
SgtCoDFish committed Oct 18, 2024
1 parent 0da68ae commit fa97d40
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 fa97d40

Please sign in to comment.