Skip to content

Commit 0d829cc

Browse files
authored
Merge pull request #506 from stuggi/OSPRH-6749
[certmanager] Allow passing annotations to CAIssuer() and add annotations keys
2 parents 09a6145 + f5a1142 commit 0d829cc

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

modules/certmanager/issuer.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ const (
4242
RootCAIssuerOvnDBLabel = "osp-rootca-issuer-ovn"
4343
// RootCAIssuerLibvirtLabel for internal RootCA to issue libvirt TLS Certs
4444
RootCAIssuerLibvirtLabel = "osp-rootca-issuer-libvirt"
45+
// CertDurationAnnotation on an issuer reflects the duration to be used for certs being issued
46+
CertDurationAnnotation = "cert-duration"
47+
// CertRenewBeforeAnnotation on an issuer reflects the renewBefore to be used for certs being issued
48+
CertRenewBeforeAnnotation = "cert-renewbefore"
49+
// CertDefaultDuration - fallback duration for certificates if no CertDurationAnnotation
50+
// annotation is set on the issuer
51+
CertDefaultDuration = "43800h0m0s"
4552
)
4653

4754
// Issuer -
@@ -86,13 +93,15 @@ func CAIssuer(
8693
name string,
8794
namespace string,
8895
labels map[string]string,
96+
annotations map[string]string,
8997
secretName string,
9098
) *certmgrv1.Issuer {
9199
return &certmgrv1.Issuer{
92100
ObjectMeta: metav1.ObjectMeta{
93-
Name: name,
94-
Namespace: namespace,
95-
Labels: labels,
101+
Name: name,
102+
Namespace: namespace,
103+
Labels: labels,
104+
Annotations: annotations,
96105
},
97106
Spec: certmgrv1.IssuerSpec{
98107
IssuerConfig: certmgrv1.IssuerConfig{

modules/certmanager/test/functional/certmanager_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ var _ = Describe("certmanager module", func() {
100100
"ca",
101101
namespace,
102102
map[string]string{"f": "l"},
103+
map[string]string{"a": "l"},
103104
"secret",
104105
),
105106
timeout,
@@ -111,6 +112,7 @@ var _ = Describe("certmanager module", func() {
111112
Expect(issuer.Spec.CA).NotTo(BeNil())
112113
Expect(issuer.Spec.CA.SecretName).To(Equal("secret"))
113114
Expect(issuer.Labels["f"]).To(Equal("l"))
115+
Expect(issuer.Annotations["a"]).To(Equal("l"))
114116
})
115117

116118
It("deletes issuer", func() {
@@ -119,6 +121,7 @@ var _ = Describe("certmanager module", func() {
119121
names.IssuerName.Name,
120122
names.IssuerName.Namespace,
121123
map[string]string{"f": "l"},
124+
map[string]string{},
122125
"secret",
123126
),
124127
timeout,
@@ -200,6 +203,7 @@ var _ = Describe("certmanager module", func() {
200203
"ca",
201204
names.Namespace,
202205
map[string]string{"f": "l"},
206+
map[string]string{},
203207
"secret",
204208
),
205209
timeout,
@@ -258,6 +262,7 @@ var _ = Describe("certmanager module", func() {
258262
"ca",
259263
names.Namespace,
260264
map[string]string{"f": "l"},
265+
map[string]string{},
261266
"secret",
262267
),
263268
timeout,
@@ -314,6 +319,7 @@ var _ = Describe("certmanager module", func() {
314319
"ca",
315320
names.Namespace,
316321
map[string]string{"f": "l"},
322+
map[string]string{},
317323
"secret",
318324
),
319325
timeout,

0 commit comments

Comments
 (0)