diff --git a/staging/src/k8s.io/apimachinery/pkg/api/validate/each.go b/staging/src/k8s.io/apimachinery/pkg/api/validate/each.go index 89994c8f07e..3d5bd3c1e70 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/validate/each.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/validate/each.go @@ -146,7 +146,7 @@ func Unique[T any](_ context.Context, _ operation.Operation, fldPath *field.Path // the key(s). Unfortunately, the way errors are rendered, it comes out // as something like "map[string]any{...}" which is not very nice. Once // that is fixed, we can consider adding a way for this function to - // specify that just the keys should be renderted in the error. + // specify that just the keys should be rendered in the error. errs = append(errs, field.Duplicate(fldPath.Index(i), val)) } return errs diff --git a/staging/src/k8s.io/apimachinery/pkg/api/validate/required.go b/staging/src/k8s.io/apimachinery/pkg/api/validate/required.go index d1829400d96..61a253a9d81 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/validate/required.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/validate/required.go @@ -83,7 +83,7 @@ func ForbiddenSlice[T any](_ context.Context, _ operation.Operation, fldPath *fi return field.ErrorList{field.Forbidden(fldPath, "")} } -// RequiredMap verifies that the specified map is empty. +// ForbiddenMap verifies that the specified map is empty. func ForbiddenMap[K comparable, T any](_ context.Context, _ operation.Operation, fldPath *field.Path, value, _ map[K]T) field.ErrorList { if len(value) == 0 { return nil diff --git a/staging/src/k8s.io/apimachinery/pkg/api/validate/union.go b/staging/src/k8s.io/apimachinery/pkg/api/validate/union.go index 06f7ef6f01c..af5e933e9d3 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/validate/union.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/validate/union.go @@ -77,8 +77,8 @@ func Union[T any](_ context.Context, op operation.Operation, fldPath *field.Path // // For example: // -// var UnionMembershipForABC := validate.NewDiscriminatedUnionMembership("type", [2]string{"a", "A"}, [2]string{"b" "B"}, [2]string{"c", "C"}) -// func ValidateABC(ctx context.Context, op operation.Operation, fldPath, *field.Path, in *ABC) (errs fields.ErrorList) { +// var UnionMembershipForABC = validate.NewDiscriminatedUnionMembership("type", [2]string{"a", "A"}, [2]string{"b", "B"}, [2]string{"c", "C"}) +// func ValidateABC(ctx context.Context, op operation.Operation, fldPath *field.Path, in *ABC) (errs field.ErrorList) { // errs = append(errs, DiscriminatedUnion(ctx, op, fldPath, in, oldIn, UnionMembershipForABC, // func(in *ABC) string { return string(in.Type) }, // func(in *ABC) bool { return in.A != nil }, diff --git a/staging/src/k8s.io/apimachinery/pkg/api/validate/zeroorone.go b/staging/src/k8s.io/apimachinery/pkg/api/validate/zeroorone.go index b18b6584da4..81cef54ab47 100644 --- a/staging/src/k8s.io/apimachinery/pkg/api/validate/zeroorone.go +++ b/staging/src/k8s.io/apimachinery/pkg/api/validate/zeroorone.go @@ -31,8 +31,8 @@ import ( // // For example: // -// var ZeroOrOneOfMembershipFor := validate.NewUnionMembership([2]string{"a", "A"}, [2]string{"b", "B"}, [2]string{"c", "C"}) -// func ValidateABC(ctx context.Context, op operation.Operation, fldPath *field.Path, in *ABC) (errs fields.ErrorList) { +// var ZeroOrOneOfMembershipForABC = validate.NewUnionMembership([2]string{"a", "A"}, [2]string{"b", "B"}, [2]string{"c", "C"}) +// func ValidateABC(ctx context.Context, op operation.Operation, fldPath *field.Path, in *ABC) (errs field.ErrorList) { // errs = append(errs, ZeroOrOneOfUnion(ctx, op, fldPath, in, oldIn, UnionMembershipForABC, // func(in *ABC) bool { return in.A != nil }, // func(in *ABC) bool { return in.B != ""}, diff --git a/staging/src/k8s.io/code-generator/cmd/validation-gen/validation.go b/staging/src/k8s.io/code-generator/cmd/validation-gen/validation.go index 5a99db04bc8..830ed4dfb19 100644 --- a/staging/src/k8s.io/code-generator/cmd/validation-gen/validation.go +++ b/staging/src/k8s.io/code-generator/cmd/validation-gen/validation.go @@ -71,7 +71,7 @@ type genValidations struct { schemeRegistry types.Name } -// NewGenValidations cretes a new generator for the specified package. +// NewGenValidations creates a new generator for the specified package. func NewGenValidations(outputFilename, outputPackage string, rootTypes []*types.Type, discovered *typeDiscoverer, inputToPkg map[string]string, schemeRegistry types.Name) generator.Generator { return &genValidations{ GoGenerator: generator.GoGenerator{ @@ -1126,7 +1126,7 @@ func (g *genValidations) emitCallToOtherTypeFunc(c *generator.Context, node *typ sw.Do("errs = append(errs, $.funcName|raw$(ctx, op, fldPath, obj, oldObj)...)\n", targs) } -// emitRachetingCheck emits a equivalence check for default ratcheting. +// emitRatchetingCheck emits an equivalence check for default ratcheting. func emitRatchetingCheck(c *generator.Context, t *types.Type, sw *generator.SnippetWriter) { // Emit equivalence check for default ratcheting. targs := generator.Args{ diff --git a/staging/src/k8s.io/code-generator/cmd/validation-gen/validators/enum.go b/staging/src/k8s.io/code-generator/cmd/validation-gen/validators/enum.go index f6434cf1138..e6d7952ee13 100644 --- a/staging/src/k8s.io/code-generator/cmd/validation-gen/validators/enum.go +++ b/staging/src/k8s.io/code-generator/cmd/validation-gen/validators/enum.go @@ -69,7 +69,7 @@ func (etv *enumTagValidator) GetValidations(context Context, _ codetags.Tag) (Va var result Validations if enum, ok := etv.enumContext.EnumType(context.Type); ok { - // TODO: Avoid the "local" here. This was added to to avoid errors caused when the package is an empty string. + // TODO: Avoid the "local" here. This was added to avoid errors caused when the package is an empty string. // The correct package would be the output package but is not known here. This does not show up in generated code. // TODO: Append a consistent hash suffix to avoid generated name conflicts? supportVarName := PrivateVar{Name: "SymbolsFor" + context.Type.Name.Name, Package: "local"} diff --git a/staging/src/k8s.io/code-generator/cmd/validation-gen/validators/required.go b/staging/src/k8s.io/code-generator/cmd/validation-gen/validators/required.go index 603121a3fbe..9a1b1583d67 100644 --- a/staging/src/k8s.io/code-generator/cmd/validation-gen/validators/required.go +++ b/staging/src/k8s.io/code-generator/cmd/validation-gen/validators/required.go @@ -32,7 +32,7 @@ const ( requiredTagName = "k8s:required" optionalTagName = "k8s:optional" forbiddenTagName = "k8s:forbidden" - defaultTagName = "default" // TODO: this should evenually be +k8s:default + defaultTagName = "default" // TODO: this should eventually be +k8s:default ) func init() { diff --git a/staging/src/k8s.io/code-generator/cmd/validation-gen/validators/union.go b/staging/src/k8s.io/code-generator/cmd/validation-gen/validators/union.go index ab80d69dfab..8eb94a05544 100644 --- a/staging/src/k8s.io/code-generator/cmd/validation-gen/validators/union.go +++ b/staging/src/k8s.io/code-generator/cmd/validation-gen/validators/union.go @@ -250,7 +250,7 @@ func processUnionValidations(context Context, unions unions, varPrefix string, return Validations{}, fmt.Errorf("slice type cannot have field members") } - // TODO: Avoid the "local" here. This was added to to avoid errors caused when the package is an empty string. + // TODO: Avoid the "local" here. This was added to avoid errors caused when the package is an empty string. // The correct package would be the output package but is not known here. This does not show up in generated code. // TODO: Append a consistent hash suffix to avoid generated name conflicts? varBaseName := sanitizeName(context.Path.String() + "_" + unionName) // unionName can be ""