Skip to content

Commit f50ad91

Browse files
committed
Create a single TypeDiscoverer for all inputs
Without this we visit some types twice.
1 parent 07bcf93 commit f50ad91

File tree

1 file changed

+6
-2
lines changed
  • staging/src/k8s.io/code-generator/cmd/validation-gen

1 file changed

+6
-2
lines changed

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ func GetTargets(context *generator.Context, args *Args) []generator.Target {
171171
}
172172

173173
var targets []generator.Target
174-
linter := newLinter()
175174

176175
// First load other "input" packages. We do this as a single call because
177176
// it is MUCH faster.
@@ -242,6 +241,12 @@ func GetTargets(context *generator.Context, args *Args) []generator.Target {
242241
// Initialize all validator plugins exactly once.
243242
validator := validators.InitGlobalValidator(context)
244243

244+
// Create a type discoverer for all types of all inputs.
245+
td := NewTypeDiscoverer(validator, inputToPkg)
246+
247+
// Create a linter to collect errors as we go.
248+
linter := newLinter()
249+
245250
// Build a cache of type->callNode for every type we need.
246251
for _, input := range context.Inputs {
247252
klog.V(2).InfoS("processing", "pkg", input)
@@ -303,7 +308,6 @@ func GetTargets(context *generator.Context, args *Args) []generator.Target {
303308
return cmp.Compare(a.Name.String(), b.Name.String())
304309
})
305310

306-
td := NewTypeDiscoverer(validator, inputToPkg)
307311
for _, t := range rootTypes {
308312
klog.V(4).InfoS("pre-processing", "type", t)
309313
if err := td.DiscoverType(t); err != nil {

0 commit comments

Comments
 (0)