@@ -100,6 +100,11 @@ type StableConfigTypeSpec struct {
100100 // subnetsWithExclusions demonstrates how to validate a list of subnets with exclusions
101101 // +optional
102102 SubnetsWithExclusions SubnetsWithExclusions `json:"subnetsWithExclusions,omitempty"`
103+
104+ // formatMarkerExamples demonstrates all Kubebuilder Format markers supported as of Kubernetes 1.33.
105+ // This field serves as a comprehensive reference for format marker validation.
106+ // +optional
107+ FormatMarkerExamples * FormatMarkerExamples `json:"formatMarkerExamples,omitempty"`
103108}
104109
105110// SetValue defines the types allowed in string set type
@@ -208,6 +213,157 @@ type SubnetsWithExclusions struct {
208213// +kubebuilder:validation:MaxLength:=43
209214type CIDR string
210215
216+ // FormatMarkerExamples demonstrates all Kubebuilder Format markers supported as of Kubernetes 1.33.
217+ // This struct provides a comprehensive reference for format marker validation.
218+ // Each field uses a different format marker to validate its value.
219+ type FormatMarkerExamples struct {
220+ // ipv4Address must be a valid IPv4 address in dotted-quad notation.
221+ // Valid values range from 0.0.0.0 to 255.255.255.255 (e.g., 192.168.1.1).
222+ //
223+ // Use of Format=ipv4 is not recommended due to CVE-2021-29923 and CVE-2024-24790.
224+ // Instead, use the CEL expression `isIP(self) && ip(self).family() == 4` to validate IPv4 addresses.
225+ //
226+ // +kubebuilder:validation:Format=ipv4
227+ // +kubebuilder:validation:MinLength=1
228+ // +kubebuilder:validation:MaxLength=15
229+ // +optional
230+ IPv4Address string `json:"ipv4Address,omitempty"`
231+
232+ // ipv6Address must be a valid IPv6 address.
233+ // Valid examples include full form (2001:0db8:0000:0000:0000:0000:0000:0001) or compressed form (2001:db8::1 or ::1).
234+ //
235+ // Use of Format=ipv6 is not recommended due to CVE-2021-29923 and CVE-2024-24790.
236+ // Instead, use the CEL expression `isIP(self) && ip(self).family() == 6` to validate IPv6 addresses.
237+ //
238+ // +kubebuilder:validation:Format=ipv6
239+ // +kubebuilder:validation:MinLength=1
240+ // +kubebuilder:validation:MaxLength=45
241+ // +optional
242+ IPv6Address string `json:"ipv6Address,omitempty"`
243+
244+ // cidrNotation must be a valid CIDR notation IP address range.
245+ // Valid examples include IPv4 CIDR (10.0.0.0/8, 192.168.1.0/24) or IPv6 CIDR (fd00::/8, 2001:db8::/32).
246+ //
247+ // Use of Format=cidr is not recommended due to CVE-2021-29923 and CVE-2024-24790.
248+ // Instead, use the CEL expression `isCIDR(self)` to validate CIDR notation.
249+ // Additionally, use `isCIDR(self) && cidr(self).ip().family() == X` to validate IPvX specifically.
250+ //
251+ // +kubebuilder:validation:Format=cidr
252+ // +kubebuilder:validation:MinLength=1
253+ // +kubebuilder:validation:MaxLength=49
254+ // +optional
255+ CIDRNotation string `json:"cidrNotation,omitempty"`
256+
257+ // uriField must be a valid URI following RFC 3986 syntax.
258+ // Valid examples include https://example.com/path?query=value or /absolute-path.
259+ // +kubebuilder:validation:Format=uri
260+ // +kubebuilder:validation:MinLength=1
261+ // +kubebuilder:validation:MaxLength=2048
262+ // +optional
263+ URIField string `json:"uriField,omitempty"`
264+
265+ // emailAddress must be a valid email address.
266+ 267+ // +kubebuilder:validation:Format=email
268+ // +kubebuilder:validation:MinLength=1
269+ // +kubebuilder:validation:MaxLength=254
270+ // +optional
271+ EmailAddress string `json:"emailAddress,omitempty"`
272+
273+ // hostnameField must be a valid Internet hostname per RFC 1034.
274+ // Valid examples include example.com, api.example.com, or my-service.
275+ // +kubebuilder:validation:Format=hostname
276+ // +kubebuilder:validation:MinLength=1
277+ // +kubebuilder:validation:MaxLength=253
278+ // +optional
279+ HostnameField string `json:"hostnameField,omitempty"`
280+
281+ // macAddress must be a valid MAC address.
282+ // Valid examples include 00:1A:2B:3C:4D:5E or 00-1A-2B-3C-4D-5E.
283+ // +kubebuilder:validation:Format=mac
284+ // +kubebuilder:validation:MinLength=1
285+ // +kubebuilder:validation:MaxLength=17
286+ // +optional
287+ MACAddress string `json:"macAddress,omitempty"`
288+
289+ // uuidField must be a valid UUID (any version) in 8-4-4-4-12 format.
290+ // Valid examples include 550e8400-e29b-41d4-a716-446655440000 or 123e4567-e89b-12d3-a456-426614174000.
291+ // +kubebuilder:validation:Format=uuid
292+ // +kubebuilder:validation:MinLength=36
293+ // +kubebuilder:validation:MaxLength=36
294+ // +optional
295+ UUIDField string `json:"uuidField,omitempty"`
296+
297+ // uuid3Field must be a valid UUID version 3 (MD5 hash-based).
298+ // Version 3 UUIDs are generated using MD5 hashing of a namespace and name.
299+ // Valid example: a3bb189e-8bf9-3888-9912-ace4e6543002.
300+ // +kubebuilder:validation:Format=uuid3
301+ // +kubebuilder:validation:MinLength=36
302+ // +kubebuilder:validation:MaxLength=36
303+ // +optional
304+ UUID3Field string `json:"uuid3Field,omitempty"`
305+
306+ // uuid4Field must be a valid UUID version 4 (random).
307+ // Version 4 UUIDs are randomly generated.
308+ // Valid example: 550e8400-e29b-41d4-a716-446655440000.
309+ // +kubebuilder:validation:Format=uuid4
310+ // +kubebuilder:validation:MinLength=36
311+ // +kubebuilder:validation:MaxLength=36
312+ // +optional
313+ UUID4Field string `json:"uuid4Field,omitempty"`
314+
315+ // uuid5Field must be a valid UUID version 5 (SHA-1 hash-based).
316+ // Version 5 UUIDs are generated using SHA-1 hashing of a namespace and name.
317+ // Valid example: 74738ff5-5367-5958-9aee-98fffdcd1876.
318+ // +kubebuilder:validation:Format=uuid5
319+ // +kubebuilder:validation:MinLength=36
320+ // +kubebuilder:validation:MaxLength=36
321+ // +optional
322+ UUID5Field string `json:"uuid5Field,omitempty"`
323+
324+ // dateField must be a valid date in RFC 3339 full-date format (YYYY-MM-DD).
325+ // Valid examples include 2024-01-15 or 2023-12-31.
326+ // +kubebuilder:validation:Format=date
327+ // +kubebuilder:validation:MinLength=10
328+ // +kubebuilder:validation:MaxLength=10
329+ // +optional
330+ DateField string `json:"dateField,omitempty"`
331+
332+ // dateTimeField must be a valid RFC 3339 date-time.
333+ // Valid examples include 2024-01-15T14:30:00Z, 2024-01-15T14:30:00+00:00, or 2024-01-15T14:30:00.123Z.
334+ // +kubebuilder:validation:Format=date-time
335+ // +kubebuilder:validation:MinLength=20
336+ // +kubebuilder:validation:MaxLength=35
337+ // +optional
338+ DateTimeField string `json:"dateTimeField,omitempty"`
339+
340+ // durationField must be a valid duration string parseable by Go's time.ParseDuration.
341+ // Valid time units are ns, us (or µs), ms, s, m, h.
342+ // Valid examples include 30s, 5m, 1h30m, 100ms, or 1h.
343+ // +kubebuilder:validation:Format=duration
344+ // +kubebuilder:validation:MinLength=1
345+ // +kubebuilder:validation:MaxLength=255
346+ // +optional
347+ DurationField string `json:"durationField,omitempty"`
348+
349+ // base64Data must be valid base64-encoded data.
350+ // Valid examples include aGVsbG8= (encodes "hello") or SGVsbG8gV29ybGQh (encodes "Hello World!").
351+ // +kubebuilder:validation:Format=byte
352+ // +kubebuilder:validation:MinLength=1
353+ // +kubebuilder:validation:MaxLength=2048
354+ // +optional
355+ Base64Data string `json:"base64Data,omitempty"`
356+
357+ // passwordField is a marker for sensitive data.
358+ // Note that the password format marker does not perform any actual validation - it accepts any string value.
359+ // This marker is primarily used to signal that the field contains sensitive information.
360+ // +kubebuilder:validation:Format=password
361+ // +kubebuilder:validation:MinLength=1
362+ // +kubebuilder:validation:MaxLength=255
363+ // +optional
364+ PasswordField string `json:"passwordField,omitempty"`
365+ }
366+
211367// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
212368// +openshift:compatibility-gen:level=1
213369
0 commit comments