Skip to content

Commit a8f2771

Browse files
committed
feat: add api validation for auth config
Signed-off-by: Bence Csati <[email protected]>
1 parent 36cc9c3 commit a8f2771

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

api/telemetry/v1alpha1/output_types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ type OutputSpec struct {
6969
Batch *Batch `json:"batch,omitempty"`
7070
}
7171

72+
// +kubebuilder:validation:XValidation:rule="(has(self.basicAuth) && has(self.bearerAuth)) == false",message="Only one authentication method can be specified: either basicAuth or bearerAuth, not both"
73+
7274
// Output Authentication configuration.
7375
type OutputAuth struct {
74-
BasicAuth *BasicAuthConfig `json:"basicauth,omitempty"`
75-
BearerAuth *BearerAuthConfig `json:"bearerauth,omitempty"`
76+
BasicAuth *BasicAuthConfig `json:"basicAuth,omitempty"`
77+
BearerAuth *BearerAuthConfig `json:"bearerAuth,omitempty"`
7678
}
7779

7880
type BasicAuthConfig struct {

charts/telemetry-controller/crds/telemetry.kube-logging.dev_outputs.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ spec:
5151
authentication:
5252
description: Output Authentication configuration.
5353
properties:
54-
basicauth:
54+
basicAuth:
5555
properties:
5656
passwordField:
5757
type: string
@@ -73,7 +73,7 @@ spec:
7373
usernameField:
7474
type: string
7575
type: object
76-
bearerauth:
76+
bearerAuth:
7777
properties:
7878
secretRef:
7979
description: |-
@@ -94,6 +94,10 @@ spec:
9494
type: string
9595
type: object
9696
type: object
97+
x-kubernetes-validations:
98+
- message: 'Only one authentication method can be specified: either
99+
basicAuth or bearerAuth, not both'
100+
rule: (has(self.basicAuth) && has(self.bearerAuth)) == false
97101
batch:
98102
description: Batch processor configuration.
99103
properties:

config/crd/bases/telemetry.kube-logging.dev_outputs.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ spec:
5151
authentication:
5252
description: Output Authentication configuration.
5353
properties:
54-
basicauth:
54+
basicAuth:
5555
properties:
5656
passwordField:
5757
type: string
@@ -73,7 +73,7 @@ spec:
7373
usernameField:
7474
type: string
7575
type: object
76-
bearerauth:
76+
bearerAuth:
7777
properties:
7878
secretRef:
7979
description: |-
@@ -94,6 +94,10 @@ spec:
9494
type: string
9595
type: object
9696
type: object
97+
x-kubernetes-validations:
98+
- message: 'Only one authentication method can be specified: either
99+
basicAuth or bearerAuth, not both'
100+
rule: (has(self.basicAuth) && has(self.bearerAuth)) == false
97101
batch:
98102
description: Batch processor configuration.
99103
properties:

0 commit comments

Comments
 (0)