Apply cert name label to created secrets

This commit is contained in:
Louis Taylor 2018-07-06 18:02:13 +01:00
parent 2ef08e2b3c
commit d60f4b447e
No known key found for this signature in database
GPG Key ID: 8E81A6DAE13E7098
2 changed files with 7 additions and 0 deletions

View File

@ -25,6 +25,7 @@ const (
CommonNameAnnotationKey = "certmanager.k8s.io/common-name"
IssuerNameAnnotationKey = "certmanager.k8s.io/issuer-name"
IssuerKindAnnotationKey = "certmanager.k8s.io/issuer-kind"
CertificateNameKey = "certmanager.k8s.io/certificate-name"
)
// +genclient

View File

@ -234,6 +234,12 @@ func (c *Controller) updateSecret(crt *v1alpha1.Certificate, namespace string, c
secret.Annotations[v1alpha1.IssuerNameAnnotationKey] = crt.Spec.IssuerRef.Name
secret.Annotations[v1alpha1.IssuerKindAnnotationKey] = issuerKind(crt)
if secret.Labels == nil {
secret.Labels = make(map[string]string)
}
secret.Labels[v1alpha1.CertificateNameKey] = crt.Name
// if it is a new resource
if secret.SelfLink == "" {
secret, err = c.client.CoreV1().Secrets(namespace).Create(secret)