Skip to content

Commit 75433e7

Browse files
feat: enforce rule into the .spec.external.tls block to avoid insecureSkipVerify and certSecretRef be set at the same time
1 parent c1dfb7a commit 75433e7

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

api/v1beta1/grafana_types.go

+3
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@ type External struct {
9090
// AdminPassword key to talk to the external grafana instance.
9191
AdminPassword *v1.SecretKeySelector `json:"adminPassword,omitempty"`
9292
// TLS Configuration used to talk with the external grafana instance.
93+
// +optional
9394
TLS *ExternalTLSConfig `json:"tls,omitempty"`
9495
}
9596

97+
// TLS Configuration to an external Grafana endpoint
98+
// +kubebuilder:validation:XValidation:rule="(has(self.insecureSkipVerify) && !(has(self.certSecretRef))) || (has(self.certSecretRef) && !(has(self.insecureSkipVerify)))", message="insecureSkipVerify and certSecretRef cannot be set at the same time"
9699
type ExternalTLSConfig struct {
97100
// Disable the CA check of the server
98101
// +optional

config/crd/bases/grafana.integreatly.org_grafanas.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -8277,6 +8277,11 @@ spec:
82778277
description: Disable the CA check of the server
82788278
type: boolean
82798279
type: object
8280+
x-kubernetes-validations:
8281+
- message: insecureSkipVerify and certSecretRef cannot be set
8282+
at the same time
8283+
rule: (has(self.insecureSkipVerify) && !(has(self.certSecretRef)))
8284+
|| (has(self.certSecretRef) && !(has(self.insecureSkipVerify)))
82808285
url:
82818286
description: URL of the external grafana instance you want to
82828287
manage.

deploy/helm/grafana-operator/crds/grafana.integreatly.org_grafanas.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -8277,6 +8277,11 @@ spec:
82778277
description: Disable the CA check of the server
82788278
type: boolean
82798279
type: object
8280+
x-kubernetes-validations:
8281+
- message: insecureSkipVerify and certSecretRef cannot be set
8282+
at the same time
8283+
rule: (has(self.insecureSkipVerify) && !(has(self.certSecretRef)))
8284+
|| (has(self.certSecretRef) && !(has(self.insecureSkipVerify)))
82808285
url:
82818286
description: URL of the external grafana instance you want to
82828287
manage.

deploy/kustomize/base/crds.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -9726,6 +9726,11 @@ spec:
97269726
description: Disable the CA check of the server
97279727
type: boolean
97289728
type: object
9729+
x-kubernetes-validations:
9730+
- message: insecureSkipVerify and certSecretRef cannot be set
9731+
at the same time
9732+
rule: (has(self.insecureSkipVerify) && !(has(self.certSecretRef)))
9733+
|| (has(self.certSecretRef) && !(has(self.insecureSkipVerify)))
97299734
url:
97309735
description: URL of the external grafana instance you want to
97319736
manage.

docs/docs/api.md

+2
Original file line numberDiff line numberDiff line change
@@ -18737,6 +18737,8 @@ External enables you to configure external grafana instances that is not managed
1873718737
<td>object</td>
1873818738
<td>
1873918739
TLS Configuration used to talk with the external grafana instance.<br/>
18740+
<br/>
18741+
<i>Validations</i>:<li>(has(self.insecureSkipVerify) && !(has(self.certSecretRef))) || (has(self.certSecretRef) && !(has(self.insecureSkipVerify))): insecureSkipVerify and certSecretRef cannot be set at the same time</li>
1874018742
</td>
1874118743
<td>false</td>
1874218744
</tr></tbody>

0 commit comments

Comments
 (0)