Skip to content

Commit 40af9fb

Browse files
committed
feat: validate cert/key pairs
1 parent d4edf98 commit 40af9fb

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

charts/operator/crds/monitoring.googleapis.com_clusterpodmonitorings.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ spec:
351351
for the targets.
352352
type: string
353353
type: object
354+
x-kubernetes-validations:
355+
- message: client cert and client key must be provided together,
356+
when either is provided
357+
rule: has(self.cert) == has(self.key)
354358
tokenURL:
355359
description: TokenURL is the URL to fetch the token from.
356360
type: string
@@ -497,6 +501,10 @@ spec:
497501
the targets.
498502
type: string
499503
type: object
504+
x-kubernetes-validations:
505+
- message: client cert and client key must be provided together,
506+
when either is provided
507+
rule: has(self.cert) == has(self.key)
500508
required:
501509
- port
502510
type: object

charts/operator/crds/monitoring.googleapis.com_podmonitorings.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ spec:
351351
for the targets.
352352
type: string
353353
type: object
354+
x-kubernetes-validations:
355+
- message: client cert and client key must be provided together,
356+
when either is provided
357+
rule: has(self.cert) == has(self.key)
354358
tokenURL:
355359
description: TokenURL is the URL to fetch the token from.
356360
type: string
@@ -497,6 +501,10 @@ spec:
497501
the targets.
498502
type: string
499503
type: object
504+
x-kubernetes-validations:
505+
- message: client cert and client key must be provided together,
506+
when either is provided
507+
rule: has(self.cert) == has(self.key)
500508
required:
501509
- port
502510
type: object

manifests/setup.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,9 @@ spec:
585585
description: ServerName is used to verify the hostname for the targets.
586586
type: string
587587
type: object
588+
x-kubernetes-validations:
589+
- message: client cert and client key must be provided together, when either is provided
590+
rule: has(self.cert) == has(self.key)
588591
tokenURL:
589592
description: TokenURL is the URL to fetch the token from.
590593
type: string
@@ -721,6 +724,9 @@ spec:
721724
description: ServerName is used to verify the hostname for the targets.
722725
type: string
723726
type: object
727+
x-kubernetes-validations:
728+
- message: client cert and client key must be provided together, when either is provided
729+
rule: has(self.cert) == has(self.key)
724730
required:
725731
- port
726732
type: object
@@ -2880,6 +2886,9 @@ spec:
28802886
description: ServerName is used to verify the hostname for the targets.
28812887
type: string
28822888
type: object
2889+
x-kubernetes-validations:
2890+
- message: client cert and client key must be provided together, when either is provided
2891+
rule: has(self.cert) == has(self.key)
28832892
tokenURL:
28842893
description: TokenURL is the URL to fetch the token from.
28852894
type: string
@@ -3016,6 +3025,9 @@ spec:
30163025
description: ServerName is used to verify the hostname for the targets.
30173026
type: string
30183027
type: object
3028+
x-kubernetes-validations:
3029+
- message: client cert and client key must be provided together, when either is provided
3030+
rule: has(self.cert) == has(self.key)
30193031
required:
30203032
- port
30213033
type: object

pkg/operator/apis/monitoring/v1/http_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ func (c *BasicAuth) ToPrometheusConfig(m PodMonitoringCRD, pool PrometheusSecret
161161
}
162162

163163
// TLS specifies TLS configuration used for HTTP requests.
164+
// +kubebuilder:validation:XValidation:rule=has(self.cert) == has(self.key),message="client cert and client key must be provided together, when either is provided"
164165
type TLS struct {
165166
// ServerName is used to verify the hostname for the targets.
166167
// +optional

0 commit comments

Comments
 (0)