Merge pull request #101624 from tilt-dev/nicks/go-to-protobuf

go-to-protobuf: small fixes to improve debuggability
This commit is contained in:
Kubernetes Prow Robot 2021-07-04 14:22:18 -07:00 committed by GitHub
commit 39e951a08d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -23,11 +23,13 @@ import (
flag "github.com/spf13/pflag"
"k8s.io/code-generator/cmd/go-to-protobuf/protobuf"
"k8s.io/klog/v2"
)
var g = protobuf.New()
func init() {
klog.InitFlags(nil)
g.BindFlags(flag.CommandLine)
goflag.Set("logtostderr", "true")
flag.CommandLine.AddGoFlagSet(goflag.CommandLine)

View File

@ -364,7 +364,12 @@ func Run(g *Generator) {
func deps(c *generator.Context, pkgs []*protobufPackage) map[string][]string {
ret := map[string][]string{}
for _, p := range pkgs {
for _, d := range c.Universe[p.PackagePath].Imports {
pkg, ok := c.Universe[p.PackagePath]
if !ok {
log.Fatalf("Unrecognized package: %s", p.PackagePath)
}
for _, d := range pkg.Imports {
ret[p.PackagePath] = append(ret[p.PackagePath], d.Path)
}
}