@@ -164,95 +164,94 @@ func init() {
164164 AllDefinitions = append (AllDefinitions , ValidationIshMarkers ... )
165165}
166166
167- // +controllertools:marker:generateHelp:category="CRD validation"
168167// Maximum specifies the maximum numeric value that this field can have.
168+ // +controllertools:marker:generateHelp:category="CRD validation"
169169type Maximum float64
170170
171171func (m Maximum ) Value () float64 {
172172 return float64 (m )
173173}
174174
175- // +controllertools:marker:generateHelp:category="CRD validation"
176175// Minimum specifies the minimum numeric value that this field can have. Negative numbers are supported.
176+ // +controllertools:marker:generateHelp:category="CRD validation"
177177type Minimum float64
178178
179179func (m Minimum ) Value () float64 {
180180 return float64 (m )
181181}
182182
183- // +controllertools:marker:generateHelp:category="CRD validation"
184183// ExclusiveMinimum indicates that the minimum is "up to" but not including that value.
184+ // +controllertools:marker:generateHelp:category="CRD validation"
185185type ExclusiveMinimum bool
186186
187- // +controllertools:marker:generateHelp:category="CRD validation"
188187// ExclusiveMaximum indicates that the maximum is "up to" but not including that value.
188+ // +controllertools:marker:generateHelp:category="CRD validation"
189189type ExclusiveMaximum bool
190190
191- // +controllertools:marker:generateHelp:category="CRD validation"
192191// MultipleOf specifies that this field must have a numeric value that's a multiple of this one.
192+ // +controllertools:marker:generateHelp:category="CRD validation"
193193type MultipleOf float64
194194
195195func (m MultipleOf ) Value () float64 {
196196 return float64 (m )
197197}
198198
199- // +controllertools:marker:generateHelp:category="CRD validation"
200199// MaxLength specifies the maximum length for this string.
200+ // +controllertools:marker:generateHelp:category="CRD validation"
201201type MaxLength int
202202
203- // +controllertools:marker:generateHelp:category="CRD validation"
204203// MinLength specifies the minimum length for this string.
204+ // +controllertools:marker:generateHelp:category="CRD validation"
205205type MinLength int
206206
207- // +controllertools:marker:generateHelp:category="CRD validation"
208207// Pattern specifies that this string must match the given regular expression.
208+ // +controllertools:marker:generateHelp:category="CRD validation"
209209type Pattern string
210210
211- // +controllertools:marker:generateHelp:category="CRD validation"
212211// MaxItems specifies the maximum length for this list.
212+ // +controllertools:marker:generateHelp:category="CRD validation"
213213type MaxItems int
214214
215- // +controllertools:marker:generateHelp:category="CRD validation"
216215// MinItems specifies the minimum length for this list.
216+ // +controllertools:marker:generateHelp:category="CRD validation"
217217type MinItems int
218218
219- // +controllertools:marker:generateHelp:category="CRD validation"
220219// UniqueItems specifies that all items in this list must be unique.
220+ // +controllertools:marker:generateHelp:category="CRD validation"
221221type UniqueItems bool
222222
223- // +controllertools:marker:generateHelp:category="CRD validation"
224223// MaxProperties restricts the number of keys in an object
224+ // +controllertools:marker:generateHelp:category="CRD validation"
225225type MaxProperties int
226226
227- // +controllertools:marker:generateHelp:category="CRD validation"
228227// MinProperties restricts the number of keys in an object
228+ // +controllertools:marker:generateHelp:category="CRD validation"
229229type MinProperties int
230230
231- // +controllertools:marker:generateHelp:category="CRD validation"
232231// Enum specifies that this (scalar) field is restricted to the *exact* values specified here.
232+ // +controllertools:marker:generateHelp:category="CRD validation"
233233type Enum []interface {}
234234
235- // +controllertools:marker:generateHelp:category="CRD validation"
236235// Format specifies additional "complex" formatting for this field.
237236//
238237// For example, a date-time field would be marked as "type: string" and
239238// "format: date-time".
239+ // +controllertools:marker:generateHelp:category="CRD validation"
240240type Format string
241241
242- // +controllertools:marker:generateHelp:category="CRD validation"
243242// Type overrides the type for this field (which defaults to the equivalent of the Go type).
244243//
245244// This generally must be paired with custom serialization. For example, the
246245// metav1.Time field would be marked as "type: string" and "format: date-time".
246+ // +controllertools:marker:generateHelp:category="CRD validation"
247247type Type string
248248
249- // +controllertools:marker:generateHelp:category="CRD validation"
250249// Nullable marks this field as allowing the "null" value.
251250//
252251// This is often not necessary, but may be helpful with custom serialization.
252+ // +controllertools:marker:generateHelp:category="CRD validation"
253253type Nullable struct {}
254254
255- // +controllertools:marker:generateHelp:category="CRD validation"
256255// Default sets the default value for this field.
257256//
258257// A default value will be accepted as any value valid for the
@@ -261,23 +260,23 @@ type Nullable struct{}
261260// "delete"}`). Defaults should be defined in pruned form, and only best-effort
262261// validation will be performed. Full validation of a default requires
263262// submission of the containing CRD to an apiserver.
263+ // +controllertools:marker:generateHelp:category="CRD validation"
264264type Default struct {
265265 Value interface {}
266266}
267267
268- // +controllertools:marker:generateHelp:category="CRD validation"
269268// Title sets the title for this field.
270269//
271270// The title is metadata that makes the OpenAPI documentation more user-friendly,
272271// making the schema more understandable when viewed in documentation tools.
273272// It's a metadata field that doesn't affect validation but provides
274273// important context about what the schema represents.
274+ // +controllertools:marker:generateHelp:category="CRD validation"
275275type Title struct {
276276 Value interface {}
277277}
278278
279- // +controllertools:marker:generateHelp:category="CRD validation"
280- // Default sets the default value for this field.
279+ // KubernetesDefault sets the default value for this field.
281280//
282281// A default value will be accepted as any value valid for the field.
283282// Only JSON-formatted values are accepted. `ref(...)` values are ignored.
@@ -286,11 +285,11 @@ type Title struct {
286285// "delete"}`). Defaults should be defined in pruned form, and only best-effort
287286// validation will be performed. Full validation of a default requires
288287// submission of the containing CRD to an apiserver.
288+ // +controllertools:marker:generateHelp:category="CRD validation"
289289type KubernetesDefault struct {
290290 Value interface {}
291291}
292292
293- // +controllertools:marker:generateHelp:category="CRD validation"
294293// Example sets the example value for this field.
295294//
296295// An example value will be accepted as any value valid for the
@@ -299,12 +298,12 @@ type KubernetesDefault struct {
299298// "delete"}`). Examples should be defined in pruned form, and only best-effort
300299// validation will be performed. Full validation of an example requires
301300// submission of the containing CRD to an apiserver.
301+ // +controllertools:marker:generateHelp:category="CRD validation"
302302type Example struct {
303303 Value interface {}
304304}
305305
306- // +controllertools:marker:generateHelp:category="CRD processing"
307- // PreserveUnknownFields stops the apiserver from pruning fields which are not specified.
306+ // XPreserveUnknownFields stops the apiserver from pruning fields which are not specified.
308307//
309308// By default the apiserver drops unknown fields from the request payload
310309// during the decoding step. This marker stops the API server from doing so.
@@ -316,33 +315,34 @@ type Example struct {
316315// NB: The kubebuilder:validation:XPreserveUnknownFields variant is deprecated
317316// in favor of the kubebuilder:pruning:PreserveUnknownFields variant. They function
318317// identically.
318+ // +controllertools:marker:generateHelp:category="CRD processing"
319319type XPreserveUnknownFields struct {}
320320
321- // +controllertools:marker:generateHelp:category="CRD validation"
322- // EmbeddedResource marks a fields as an embedded resource with apiVersion, kind and metadata fields.
321+ // XEmbeddedResource marks a fields as an embedded resource with apiVersion, kind and metadata fields.
323322//
324323// An embedded resource is a value that has apiVersion, kind and metadata fields.
325324// They are validated implicitly according to the semantics of the currently
326325// running apiserver. It is not necessary to add any additional schema for these
327326// field, yet it is possible. This can be combined with PreserveUnknownFields.
327+ // +controllertools:marker:generateHelp:category="CRD validation"
328328type XEmbeddedResource struct {}
329329
330- // +controllertools:marker:generateHelp:category="CRD validation"
331- // IntOrString marks a fields as an IntOrString.
330+ // XIntOrString marks a fields as an IntOrString.
332331//
333332// This is required when applying patterns or other validations to an IntOrString
334333// field. Known information about the type is applied during the collapse phase
335334// and as such is not normally available during marker application.
335+ // +controllertools:marker:generateHelp:category="CRD validation"
336336type XIntOrString struct {}
337337
338- // +controllertools:marker:generateHelp:category="CRD validation"
339338// Schemaless marks a field as being a schemaless object.
340339//
341340// Schemaless objects are not introspected, so you must provide
342341// any type and validation information yourself. One use for this
343342// tag is for embedding fields that hold JSONSchema typed objects.
344343// Because this field disables all type checking, it is recommended
345344// to be used only as a last resort.
345+ // +controllertools:marker:generateHelp:category="CRD validation"
346346type Schemaless struct {}
347347
348348func hasNumericType (schema * apiext.JSONSchemaProps ) bool {
@@ -357,12 +357,12 @@ func isIntegral(value float64) bool {
357357 return value == math .Trunc (value ) && ! math .IsNaN (value ) && ! math .IsInf (value , 0 )
358358}
359359
360- // +controllertools:marker:generateHelp:category="CRD validation"
361360// XValidation marks a field as requiring a value for which a given
362361// expression evaluates to true.
363362//
364363// This marker may be repeated to specify multiple expressions, all of
365364// which must evaluate to true.
365+ // +controllertools:marker:generateHelp:category="CRD validation"
366366type XValidation struct {
367367 Rule string
368368 Message string `marker:",optional"`
@@ -372,22 +372,22 @@ type XValidation struct {
372372 OptionalOldSelf * bool `marker:"optionalOldSelf,optional"`
373373}
374374
375- // +controllertools:marker:generateHelp:category="CRD validation"
376375// AtMostOneOf adds a validation constraint that allows at most one of the specified fields.
377376//
378377// This marker may be repeated to specify multiple AtMostOneOf constraints that are mutually exclusive.
378+ // +controllertools:marker:generateHelp:category="CRD validation"
379379type AtMostOneOf []string
380380
381- // +controllertools:marker:generateHelp:category="CRD validation"
382381// ExactlyOneOf adds a validation constraint that allows at exactly one of the specified fields.
383382//
384383// This marker may be repeated to specify multiple ExactlyOneOf constraints that are mutually exclusive.
384+ // +controllertools:marker:generateHelp:category="CRD validation"
385385type ExactlyOneOf []string
386386
387- // +controllertools:marker:generateHelp:category="CRD validation"
388387// AtLeastOneOf adds a validation constraint that allows at least one of the specified fields.
389388//
390389// This marker may be repeated to specify multiple AtLeastOneOf constraints that are mutually exclusive.
390+ // +controllertools:marker:generateHelp:category="CRD validation"
391391type AtLeastOneOf []string
392392
393393func (m Maximum ) ApplyToSchema (schema * apiext.JSONSchemaProps ) error {
@@ -561,7 +561,7 @@ func (m Nullable) ApplyToSchema(schema *apiext.JSONSchemaProps) error {
561561 return nil
562562}
563563
564- // Defaults are only valid CRDs created with the v1 API
564+ // ApplyToSchema defaults are only valid CRDs created with the v1 API
565565func (m Default ) ApplyToSchema (schema * apiext.JSONSchemaProps ) error {
566566 marshalledDefault , err := json .Marshal (m .Value )
567567 if err != nil {
@@ -601,7 +601,7 @@ func (m *KubernetesDefault) ParseMarker(_ string, _ string, restFields string) e
601601 return json .Unmarshal ([]byte (restFields ), & m .Value )
602602}
603603
604- // Defaults are only valid CRDs created with the v1 API
604+ // ApplyToSchema defaults are only valid CRDs created with the v1 API
605605func (m KubernetesDefault ) ApplyToSchema (schema * apiext.JSONSchemaProps ) error {
606606 if m .Value == nil {
607607 // only apply to the schema if we have a non-nil default value
0 commit comments