Merge pull request #719 from kragniz/secret-certificate-name-label

Add certificate-name label to created secrets
This commit is contained in:
jetstack-bot 2018-07-11 13:37:43 +01:00 committed by GitHub
commit 22ba1d416b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 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)

View File

@ -49,4 +49,13 @@ func (f *Framework) WaitCertificateIssuedValidTimeout(c *v1alpha1.Certificate, t
if expectedCN != cert.Subject.CommonName || !util.EqualUnsorted(cert.DNSNames, expectedDNSNames) {
Failf("Expected certificate valid for CN %q, dnsNames %v but got a certificate valid for CN %q, dnsNames %v", expectedCN, expectedDNSNames, cert.Subject.CommonName, cert.DNSNames)
}
label, ok := secret.Labels[v1alpha1.CertificateNameKey]
if !ok {
Failf("Expected secret to have certificate-name label, but had none")
}
if label != c.Name {
Failf("Expected secret to have certificate-name label with a value of %q, but got %q", c.Name, label)
}
}