Merge pull request #130795 from thockin/kk_emit_comments_before_validations

Validation-gen: emit comments before validations
This commit is contained in:
Kubernetes Prow Robot 2025-03-14 12:31:47 -07:00 committed by GitHub
commit 3c97b23a20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

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

View File

@ -969,8 +969,8 @@ func (g *genValidations) emitValidationForChild(c *generator.Context, thisChild
panic(fmt.Sprintf("unexpected type-validations on type %v, kind %s", thisNode.valueType, thisNode.valueType.Kind)) panic(fmt.Sprintf("unexpected type-validations on type %v, kind %s", thisNode.valueType, thisNode.valueType.Kind))
} }
sw.Do("// type $.inType|raw$\n", targs) sw.Do("// type $.inType|raw$\n", targs)
emitCallsToValidators(c, validations.Functions, sw)
emitComments(validations.Comments, sw) emitComments(validations.Comments, sw)
emitCallsToValidators(c, validations.Functions, sw)
sw.Do("\n", nil) sw.Do("\n", nil)
didSome = true didSome = true
} }
@ -998,8 +998,8 @@ func (g *genValidations) emitValidationForChild(c *generator.Context, thisChild
validations := fld.fieldValidations validations := fld.fieldValidations
if !validations.Empty() { if !validations.Empty() {
emitCallsToValidators(c, validations.Functions, bufsw)
emitComments(validations.Comments, bufsw) emitComments(validations.Comments, bufsw)
emitCallsToValidators(c, validations.Functions, bufsw)
} }
// If the node is nil, this must be a type in a package we are not // If the node is nil, this must be a type in a package we are not