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 580ae0104fd..7cb8c019c14 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 @@ -354,23 +354,21 @@ func (td *typeDiscoverer) discover(t *types.Type, fldPath *field.Path) (*typeNod return node, nil } - // If we are descending into a named type, reboot the field path for better - // logging. Otherwise the field path might come in as something like - // .. which is true, but not super useful. - switch t.Kind { - case types.Alias, types.Struct: - fldPath = field.NewPath(t.Name.String()) - } - // This is the type-node being assembled in the rest of this function. thisNode := &typeNode{ valueType: t, } td.typeNodes[t] = thisNode - // If this is a known, named type, we can call its validation function. + // If we are descending into a named type... switch t.Kind { case types.Alias, types.Struct: + // Reboot the field path for better logging. Otherwise the field path + // might come in as something like .. which is + // true, but not super useful. + fldPath = field.NewPath(t.Name.String()) + + // Find its validation function for later use. if fn, ok := td.getValidationFunctionName(t); ok { thisNode.funcName = fn }