forked from cert-manager/cert-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renew.go
28 lines (21 loc) · 819 Bytes
/
renew.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package acme
import (
"context"
"github.com/jetstack-experimental/cert-manager/pkg/apis/certmanager/v1alpha1"
)
const (
errorRenewCert = "ErrRenewCert"
messageErrorRenewCert = "Error renewing TLS certificate: "
successCertRenewed = "CertRenewSuccess"
messageCertRenewed = "Certificate renewed successfully"
)
func (a *Acme) Renew(ctx context.Context, crt *v1alpha1.Certificate) ([]byte, []byte, error) {
key, cert, err := a.obtainCertificate(ctx, crt)
if err != nil {
s := messageErrorIssueCert + err.Error()
crt.UpdateStatusCondition(v1alpha1.CertificateConditionReady, v1alpha1.ConditionFalse, errorRenewCert, s)
return nil, nil, err
}
crt.UpdateStatusCondition(v1alpha1.CertificateConditionReady, v1alpha1.ConditionTrue, successCertRenewed, messageCertRenewed)
return key, cert, err
}