Skip to content

Commit 9765fe4

Browse files
committed
Add all extra_pkgs needed by main API types to validation-gen
1 parent 3a812ec commit 9765fe4

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

hack/update-codegen.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,16 @@ function codegen::validation() {
430430
tag_pkgs+=("./$dir")
431431
done
432432

433+
# This list needs to cover all of the types used transitively from the
434+
# main API types. Validations defined on types in these packages will be
435+
# used, but not regenerated, unless they are also listed as a "regular"
436+
# input on the command-line.
433437
local extra_pkgs=(
434438
k8s.io/apimachinery/pkg/apis/meta/v1
439+
k8s.io/apimachinery/pkg/api/resource
440+
k8s.io/apimachinery/pkg/runtime
441+
k8s.io/apimachinery/pkg/types
442+
k8s.io/apimachinery/pkg/util/intstr
435443
)
436444

437445
kube::log::status "Generating validation code for ${#tag_pkgs[@]} targets"

staging/src/k8s.io/code-generator/cmd/validation-gen/validation.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ import (
2727
"strings"
2828
"unicode"
2929

30-
"k8s.io/apimachinery/pkg/util/sets"
31-
"k8s.io/apimachinery/pkg/util/validation/field"
32-
"k8s.io/code-generator/cmd/validation-gen/validators"
3330
"k8s.io/gengo/v2/generator"
3431
"k8s.io/gengo/v2/namer"
3532
"k8s.io/gengo/v2/parser/tags"
3633
"k8s.io/gengo/v2/types"
3734
"k8s.io/klog/v2"
35+
36+
"k8s.io/apimachinery/pkg/util/sets"
37+
"k8s.io/apimachinery/pkg/util/validation/field"
38+
"k8s.io/code-generator/cmd/validation-gen/validators"
3839
)
3940

4041
func mkPkgNames(pkg string, names ...string) []types.Name {
@@ -345,7 +346,7 @@ func (td *typeDiscoverer) discover(t *types.Type, fldPath *field.Path) (*typeNod
345346

346347
// Discover into this type before extracting type validations.
347348
switch t.Kind {
348-
case types.Builtin:
349+
case types.Builtin, types.Interface:
349350
// Nothing more to do.
350351
case types.Alias:
351352
// Discover the underlying type.

0 commit comments

Comments
 (0)