Mark RC.Spec.MinReadySeconds as k8s:optional

+k8s:optional should be used everywhere +optional is.
This does not change the vailidation of the field, but it
is a good practice, and code generator recognizes the fields
tags and outputs this comment above the field validation
as a result: "optional value-type fields with zero-value
defaults are purely documentation".
This commit is contained in:
Joe Betz 2025-03-12 20:45:28 -04:00
parent 1e33616068
commit 177193ed19
3 changed files with 3 additions and 0 deletions

View File

@ -102,6 +102,7 @@ func Validate_ReplicationControllerSpec(ctx context.Context, op operation.Operat
errs = append(errs,
func(fldPath *field.Path, obj, oldObj *int32) (errs field.ErrorList) {
errs = append(errs, validate.Minimum(ctx, op, fldPath, obj, oldObj, 0)...)
// optional value-type fields with zero-value defaults are purely documentation
return
}(fldPath.Child("minReadySeconds"), &obj.MinReadySeconds, safe.Field(oldObj, func(oldObj *corev1.ReplicationControllerSpec) *int32 { return &oldObj.MinReadySeconds }))...)

View File

@ -5094,6 +5094,7 @@ message ReplicationControllerSpec {
// without any of its container crashing, for it to be considered available.
// Defaults to 0 (pod will be considered available as soon as it is ready)
// +optional
// +k8s:optional
// +default=0
// +k8s:minimum=0
optional int32 minReadySeconds = 4;

View File

@ -5116,6 +5116,7 @@ type ReplicationControllerSpec struct {
// without any of its container crashing, for it to be considered available.
// Defaults to 0 (pod will be considered available as soon as it is ready)
// +optional
// +k8s:optional
// +default=0
// +k8s:minimum=0
MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,4,opt,name=minReadySeconds"`