Skip to content

Commit f65ec4f

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#51053 from thockin/conversion-gen-debug
Automatic merge from submit-queue (batch tested with PRs 51114, 51233, 51024, 51053, 51197) Add debug logs to conversion-gen These were useful when tracking a different problem.
2 parents 4a4c194 + 2d55332 commit f65ec4f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

  • staging/src/k8s.io/code-generator/cmd/conversion-gen/generators

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ type conversionFuncMap map[conversionPair]*types.Type
133133

134134
// Returns all manually-defined conversion functions in the package.
135135
func getManualConversionFunctions(context *generator.Context, pkg *types.Package, manualMap conversionFuncMap) {
136+
glog.V(5).Infof("Scanning for conversion functions in %v", pkg.Name)
137+
136138
scopeName := types.Ref(conversionPackagePath, "Scope").Name
137139
errorName := types.Ref("", "error").Name
138140
buffer := &bytes.Buffer{}
@@ -147,35 +149,43 @@ func getManualConversionFunctions(context *generator.Context, pkg *types.Package
147149
glog.Errorf("Function without signature: %#v", f)
148150
continue
149151
}
152+
glog.V(8).Infof("Considering function %s", f.Name)
150153
signature := f.Underlying.Signature
151154
// Check whether the function is conversion function.
152155
// Note that all of them have signature:
153156
// func Convert_inType_To_outType(inType, outType, conversion.Scope) error
154157
if signature.Receiver != nil {
158+
glog.V(8).Infof("%s has a receiver", f.Name)
155159
continue
156160
}
157161
if len(signature.Parameters) != 3 || signature.Parameters[2].Name != scopeName {
162+
glog.V(8).Infof("%s has wrong parameters", f.Name)
158163
continue
159164
}
160165
if len(signature.Results) != 1 || signature.Results[0].Name != errorName {
166+
glog.V(8).Infof("%s has wrong results", f.Name)
161167
continue
162168
}
163169
inType := signature.Parameters[0]
164170
outType := signature.Parameters[1]
165171
if inType.Kind != types.Pointer || outType.Kind != types.Pointer {
172+
glog.V(8).Infof("%s has wrong parameter types", f.Name)
166173
continue
167174
}
168175
// Now check if the name satisfies the convention.
169176
// TODO: This should call the Namer directly.
170177
args := argsFromType(inType.Elem, outType.Elem)
171178
sw.Do("Convert_$.inType|public$_To_$.outType|public$", args)
172179
if f.Name.Name == buffer.String() {
180+
glog.V(4).Infof("Found conversion function %s", f.Name)
173181
key := conversionPair{inType.Elem, outType.Elem}
174182
// We might scan the same package twice, and that's OK.
175183
if v, ok := manualMap[key]; ok && v != nil && v.Name.Package != pkg.Path {
176184
panic(fmt.Sprintf("duplicate static conversion defined: %s -> %s", key.inType, key.outType))
177185
}
178186
manualMap[key] = f
187+
} else {
188+
glog.V(8).Infof("%s has wrong name", f.Name)
179189
}
180190
buffer.Reset()
181191
}

0 commit comments

Comments
 (0)