Skip to content

Commit 1a83425

Browse files
committed
Add CEL validation for LocalObjectReferenceWithKey struct
1 parent bc9f915 commit 1a83425

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

docs/proposals/authentication-filter.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,22 @@ type FileKeySource struct {
238238
KeyCache *v1alpha1.Duration `json:"keyCache,omitempty"`
239239
}
240240

241-
// LocalObjectReferenceWithKey sepcifies as local kubernetes object
242-
// with required `key` field to extract data.
241+
// LocalObjectReferenceWithKey specifies a local Kubernetes object
242+
// with a required `key` field to extract data.
243+
// +kubebuilder:validation:XValidation:message="name must be set",rule="self.name != ''"
243244
type LocalObjectReferenceWithKey struct {
244-
v1.LocalObjectReference
245-
Key string
245+
// Inline the core LocalObjectReference so `name` sits at the same JSON level
246+
// (optional, but avoids nesting)
247+
v1.LocalObjectReference `json:",inline"`
248+
249+
// Key must be provided and non-empty.
250+
// This makes the field required in the OpenAPI schema.
251+
// +kubebuilder:validation:MinLength=1
252+
// +kubebuilder:validation:XValidation:rule="self != ''",message="key must be non-empty"
253+
Key string `json:"key"`
246254
}
247255

256+
248257
// RemoteKeySource specifies remote JWKS configuration.
249258
type RemoteKeySource struct {
250259
// URL is the JWKS endpoint, e.g. "https://issuer.example.com/.well-known/jwks.json".

0 commit comments

Comments
 (0)