From 9f36f8984b1bb295a08b4aa9dd3ba024d9d1df4e Mon Sep 17 00:00:00 2001 From: Jonathan Prates Date: Tue, 29 Jun 2021 12:14:38 +0100 Subject: [PATCH] feat: copy SecretTemplate api to v1alpha2 v1alpha3 and v1beta1 Signed-off-by: jonathansp --- deploy/crds/crd-certificates.yaml | 42 +++++++++++++++++++ .../certmanager/v1alpha2/types_certificate.go | 17 ++++++++ .../v1alpha2/zz_generated.deepcopy.go | 35 ++++++++++++++++ .../certmanager/v1alpha3/types_certificate.go | 17 ++++++++ .../v1alpha3/zz_generated.deepcopy.go | 35 ++++++++++++++++ .../certmanager/v1beta1/types_certificate.go | 17 ++++++++ .../v1beta1/zz_generated.deepcopy.go | 35 ++++++++++++++++ .../v1alpha2/zz_generated.conversion.go | 1 + .../v1alpha3/zz_generated.conversion.go | 1 + .../v1beta1/zz_generated.conversion.go | 6 +-- 10 files changed, 201 insertions(+), 5 deletions(-) diff --git a/deploy/crds/crd-certificates.yaml b/deploy/crds/crd-certificates.yaml index 045a6d84b..ab656f97b 100644 --- a/deploy/crds/crd-certificates.yaml +++ b/deploy/crds/crd-certificates.yaml @@ -214,6 +214,20 @@ spec: secretName: description: SecretName is the name of the secret resource that will be automatically created and managed by this Certificate resource. It will be populated with a private key and certificate, signed by the denoted issuer. type: string + secretTemplate: + description: SecretTemplate defines annotations and labels to be propagated to the Kubernetes Secret when it is created or updated. + type: object + properties: + annotations: + description: Annotations is a key value map to be copied to the target Kubernetes Secret. + type: object + additionalProperties: + type: string + labels: + description: Labels is a key value map to be copied to the target Kubernetes Secret. + type: object + additionalProperties: + type: string subject: description: Full X509 name specification (https://golang.org/pkg/crypto/x509/pkix/#Name). type: object @@ -512,6 +526,20 @@ spec: secretName: description: SecretName is the name of the secret resource that will be automatically created and managed by this Certificate resource. It will be populated with a private key and certificate, signed by the denoted issuer. type: string + secretTemplate: + description: SecretTemplate defines annotations and labels to be propagated to the Kubernetes Secret when it is created or updated. + type: object + properties: + annotations: + description: Annotations is a key value map to be copied to the target Kubernetes Secret. + type: object + additionalProperties: + type: string + labels: + description: Labels is a key value map to be copied to the target Kubernetes Secret. + type: object + additionalProperties: + type: string subject: description: Full X509 name specification (https://golang.org/pkg/crypto/x509/pkix/#Name). type: object @@ -817,6 +845,20 @@ spec: secretName: description: SecretName is the name of the secret resource that will be automatically created and managed by this Certificate resource. It will be populated with a private key and certificate, signed by the denoted issuer. type: string + secretTemplate: + description: SecretTemplate defines annotations and labels to be propagated to the Kubernetes Secret when it is created or updated. + type: object + properties: + annotations: + description: Annotations is a key value map to be copied to the target Kubernetes Secret. + type: object + additionalProperties: + type: string + labels: + description: Labels is a key value map to be copied to the target Kubernetes Secret. + type: object + additionalProperties: + type: string subject: description: Full X509 name specification (https://golang.org/pkg/crypto/x509/pkix/#Name). type: object diff --git a/pkg/apis/certmanager/v1alpha2/types_certificate.go b/pkg/apis/certmanager/v1alpha2/types_certificate.go index e3394219b..7922ba467 100644 --- a/pkg/apis/certmanager/v1alpha2/types_certificate.go +++ b/pkg/apis/certmanager/v1alpha2/types_certificate.go @@ -135,6 +135,11 @@ type CertificateSpec struct { // denoted issuer. SecretName string `json:"secretName"` + // SecretTemplate defines annotations and labels to be propagated + // to the Kubernetes Secret when it is created or updated. + // +optional + SecretTemplate *CertificateSecretTemplate `json:"secretTemplate,omitempty"` + // Keystores configures additional keystore output formats stored in the // `secretName` Secret resource. // +optional @@ -423,3 +428,15 @@ const ( // It will be removed by the 'issuing' controller upon completing issuance. CertificateConditionIssuing CertificateConditionType = "Issuing" ) + +// CertificateSecretTemplate defines the default labels and annotations +// to be copied to the Kubernetes Secret resource named in `CertificateSpec.secretName`. +type CertificateSecretTemplate struct { + // Annotations is a key value map to be copied to the target Kubernetes Secret. + // +optional + Annotations map[string]string `json:"annotations,omitempty"` + + // Labels is a key value map to be copied to the target Kubernetes Secret. + // +optional + Labels map[string]string `json:"labels,omitempty"` +} diff --git a/pkg/apis/certmanager/v1alpha2/zz_generated.deepcopy.go b/pkg/apis/certmanager/v1alpha2/zz_generated.deepcopy.go index 01050439d..095589c2c 100644 --- a/pkg/apis/certmanager/v1alpha2/zz_generated.deepcopy.go +++ b/pkg/apis/certmanager/v1alpha2/zz_generated.deepcopy.go @@ -346,6 +346,36 @@ func (in *CertificateRequestStatus) DeepCopy() *CertificateRequestStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CertificateSecretTemplate) DeepCopyInto(out *CertificateSecretTemplate) { + *out = *in + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CertificateSecretTemplate. +func (in *CertificateSecretTemplate) DeepCopy() *CertificateSecretTemplate { + if in == nil { + return nil + } + out := new(CertificateSecretTemplate) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CertificateSpec) DeepCopyInto(out *CertificateSpec) { *out = *in @@ -389,6 +419,11 @@ func (in *CertificateSpec) DeepCopyInto(out *CertificateSpec) { *out = make([]string, len(*in)) copy(*out, *in) } + if in.SecretTemplate != nil { + in, out := &in.SecretTemplate, &out.SecretTemplate + *out = new(CertificateSecretTemplate) + (*in).DeepCopyInto(*out) + } if in.Keystores != nil { in, out := &in.Keystores, &out.Keystores *out = new(CertificateKeystores) diff --git a/pkg/apis/certmanager/v1alpha3/types_certificate.go b/pkg/apis/certmanager/v1alpha3/types_certificate.go index 814bf12e4..4df4107ee 100644 --- a/pkg/apis/certmanager/v1alpha3/types_certificate.go +++ b/pkg/apis/certmanager/v1alpha3/types_certificate.go @@ -133,6 +133,11 @@ type CertificateSpec struct { // denoted issuer. SecretName string `json:"secretName"` + // SecretTemplate defines annotations and labels to be propagated + // to the Kubernetes Secret when it is created or updated. + // +optional + SecretTemplate *CertificateSecretTemplate `json:"secretTemplate,omitempty"` + // Keystores configures additional keystore output formats stored in the // `secretName` Secret resource. // +optional @@ -430,3 +435,15 @@ const ( // It will be removed by the 'issuing' controller upon completing issuance. CertificateConditionIssuing CertificateConditionType = "Issuing" ) + +// CertificateSecretTemplate defines the default labels and annotations +// to be copied to the Kubernetes Secret resource named in `CertificateSpec.secretName`. +type CertificateSecretTemplate struct { + // Annotations is a key value map to be copied to the target Kubernetes Secret. + // +optional + Annotations map[string]string `json:"annotations,omitempty"` + + // Labels is a key value map to be copied to the target Kubernetes Secret. + // +optional + Labels map[string]string `json:"labels,omitempty"` +} diff --git a/pkg/apis/certmanager/v1alpha3/zz_generated.deepcopy.go b/pkg/apis/certmanager/v1alpha3/zz_generated.deepcopy.go index bcc8e3be6..3128073b4 100644 --- a/pkg/apis/certmanager/v1alpha3/zz_generated.deepcopy.go +++ b/pkg/apis/certmanager/v1alpha3/zz_generated.deepcopy.go @@ -346,6 +346,36 @@ func (in *CertificateRequestStatus) DeepCopy() *CertificateRequestStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CertificateSecretTemplate) DeepCopyInto(out *CertificateSecretTemplate) { + *out = *in + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CertificateSecretTemplate. +func (in *CertificateSecretTemplate) DeepCopy() *CertificateSecretTemplate { + if in == nil { + return nil + } + out := new(CertificateSecretTemplate) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CertificateSpec) DeepCopyInto(out *CertificateSpec) { *out = *in @@ -384,6 +414,11 @@ func (in *CertificateSpec) DeepCopyInto(out *CertificateSpec) { *out = make([]string, len(*in)) copy(*out, *in) } + if in.SecretTemplate != nil { + in, out := &in.SecretTemplate, &out.SecretTemplate + *out = new(CertificateSecretTemplate) + (*in).DeepCopyInto(*out) + } if in.Keystores != nil { in, out := &in.Keystores, &out.Keystores *out = new(CertificateKeystores) diff --git a/pkg/apis/certmanager/v1beta1/types_certificate.go b/pkg/apis/certmanager/v1beta1/types_certificate.go index 1a9f8a089..25e361747 100644 --- a/pkg/apis/certmanager/v1beta1/types_certificate.go +++ b/pkg/apis/certmanager/v1beta1/types_certificate.go @@ -134,6 +134,11 @@ type CertificateSpec struct { // denoted issuer. SecretName string `json:"secretName"` + // SecretTemplate defines annotations and labels to be propagated + // to the Kubernetes Secret when it is created or updated. + // +optional + SecretTemplate *CertificateSecretTemplate `json:"secretTemplate,omitempty"` + // Keystores configures additional keystore output formats stored in the // `secretName` Secret resource. // +optional @@ -428,3 +433,15 @@ const ( // It will be removed by the 'issuing' controller upon completing issuance. CertificateConditionIssuing CertificateConditionType = "Issuing" ) + +// CertificateSecretTemplate defines the default labels and annotations +// to be copied to the Kubernetes Secret resource named in `CertificateSpec.secretName`. +type CertificateSecretTemplate struct { + // Annotations is a key value map to be copied to the target Kubernetes Secret. + // +optional + Annotations map[string]string `json:"annotations,omitempty"` + + // Labels is a key value map to be copied to the target Kubernetes Secret. + // +optional + Labels map[string]string `json:"labels,omitempty"` +} diff --git a/pkg/apis/certmanager/v1beta1/zz_generated.deepcopy.go b/pkg/apis/certmanager/v1beta1/zz_generated.deepcopy.go index 089e5d0c5..f422b5462 100644 --- a/pkg/apis/certmanager/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/certmanager/v1beta1/zz_generated.deepcopy.go @@ -346,6 +346,36 @@ func (in *CertificateRequestStatus) DeepCopy() *CertificateRequestStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CertificateSecretTemplate) DeepCopyInto(out *CertificateSecretTemplate) { + *out = *in + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CertificateSecretTemplate. +func (in *CertificateSecretTemplate) DeepCopy() *CertificateSecretTemplate { + if in == nil { + return nil + } + out := new(CertificateSecretTemplate) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CertificateSpec) DeepCopyInto(out *CertificateSpec) { *out = *in @@ -384,6 +414,11 @@ func (in *CertificateSpec) DeepCopyInto(out *CertificateSpec) { *out = make([]string, len(*in)) copy(*out, *in) } + if in.SecretTemplate != nil { + in, out := &in.SecretTemplate, &out.SecretTemplate + *out = new(CertificateSecretTemplate) + (*in).DeepCopyInto(*out) + } if in.Keystores != nil { in, out := &in.Keystores, &out.Keystores *out = new(CertificateKeystores) diff --git a/pkg/internal/apis/certmanager/v1alpha2/zz_generated.conversion.go b/pkg/internal/apis/certmanager/v1alpha2/zz_generated.conversion.go index 2cc62fce0..d26d24850 100644 --- a/pkg/internal/apis/certmanager/v1alpha2/zz_generated.conversion.go +++ b/pkg/internal/apis/certmanager/v1alpha2/zz_generated.conversion.go @@ -743,6 +743,7 @@ func autoConvert_v1alpha2_CertificateSpec_To_certmanager_CertificateSpec(in *v1a out.URISANs = *(*[]string)(unsafe.Pointer(&in.URISANs)) out.EmailSANs = *(*[]string)(unsafe.Pointer(&in.EmailSANs)) out.SecretName = in.SecretName + // WARNING: in.SecretTemplate requires manual conversion: does not exist in peer-type if in.Keystores != nil { in, out := &in.Keystores, &out.Keystores *out = new(certmanager.CertificateKeystores) diff --git a/pkg/internal/apis/certmanager/v1alpha3/zz_generated.conversion.go b/pkg/internal/apis/certmanager/v1alpha3/zz_generated.conversion.go index 2ccb96524..de1445302 100644 --- a/pkg/internal/apis/certmanager/v1alpha3/zz_generated.conversion.go +++ b/pkg/internal/apis/certmanager/v1alpha3/zz_generated.conversion.go @@ -742,6 +742,7 @@ func autoConvert_v1alpha3_CertificateSpec_To_certmanager_CertificateSpec(in *v1a out.URISANs = *(*[]string)(unsafe.Pointer(&in.URISANs)) out.EmailSANs = *(*[]string)(unsafe.Pointer(&in.EmailSANs)) out.SecretName = in.SecretName + // WARNING: in.SecretTemplate requires manual conversion: does not exist in peer-type if in.Keystores != nil { in, out := &in.Keystores, &out.Keystores *out = new(certmanager.CertificateKeystores) diff --git a/pkg/internal/apis/certmanager/v1beta1/zz_generated.conversion.go b/pkg/internal/apis/certmanager/v1beta1/zz_generated.conversion.go index fd05961ed..e3d7c9ad5 100644 --- a/pkg/internal/apis/certmanager/v1beta1/zz_generated.conversion.go +++ b/pkg/internal/apis/certmanager/v1beta1/zz_generated.conversion.go @@ -752,6 +752,7 @@ func autoConvert_v1beta1_CertificateSpec_To_certmanager_CertificateSpec(in *v1be out.URISANs = *(*[]string)(unsafe.Pointer(&in.URISANs)) out.EmailSANs = *(*[]string)(unsafe.Pointer(&in.EmailSANs)) out.SecretName = in.SecretName + // WARNING: in.SecretTemplate requires manual conversion: does not exist in peer-type if in.Keystores != nil { in, out := &in.Keystores, &out.Keystores *out = new(certmanager.CertificateKeystores) @@ -772,11 +773,6 @@ func autoConvert_v1beta1_CertificateSpec_To_certmanager_CertificateSpec(in *v1be return nil } -// Convert_v1beta1_CertificateSpec_To_certmanager_CertificateSpec is an autogenerated conversion function. -func Convert_v1beta1_CertificateSpec_To_certmanager_CertificateSpec(in *v1beta1.CertificateSpec, out *certmanager.CertificateSpec, s conversion.Scope) error { - return autoConvert_v1beta1_CertificateSpec_To_certmanager_CertificateSpec(in, out, s) -} - func autoConvert_certmanager_CertificateSpec_To_v1beta1_CertificateSpec(in *certmanager.CertificateSpec, out *v1beta1.CertificateSpec, s conversion.Scope) error { out.Subject = (*v1beta1.X509Subject)(unsafe.Pointer(in.Subject)) out.CommonName = in.CommonName