Skip to content

Commit a83f78e

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#55948 from munnerz/patch-2
Automatic merge from submit-queue (batch tested with PRs 55841, 55948, 55945). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. conversion-gen: check for nil pkg in getManualConversionFunctions **What this PR does / why we need it**: Following kubernetes#54394, this PR performs a check in getManualConversionFunctions for packages that are not found and prints a warning instead of panicking. This should improve the UX of conversion-gen, and is also a narrower change than that proposed in kubernetes#54394, so hopefully can be cherry picked into the release-1.8 etc. branches. This would allow users to use conversion-gen via the generate-internal-groups.sh script without having to make a second call that 'blanks out' `--extra-peer-dirs`. /cc @sttts ```release-note NONE ```
2 parents 869b5ab + 58dd760 commit a83f78e

File tree

1 file changed

+4
-0
lines changed
  • staging/src/k8s.io/code-generator/cmd/conversion-gen/generators

1 file changed

+4
-0
lines changed

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

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

146146
// Returns all manually-defined conversion functions in the package.
147147
func getManualConversionFunctions(context *generator.Context, pkg *types.Package, manualMap conversionFuncMap) {
148+
if pkg == nil {
149+
glog.Warningf("Skipping nil package passed to getManualConversionFunctions")
150+
return
151+
}
148152
glog.V(5).Infof("Scanning for conversion functions in %v", pkg.Name)
149153

150154
scopeName := types.Ref(conversionPackagePath, "Scope").Name

0 commit comments

Comments
 (0)