diff --git a/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/cmd.go b/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/cmd.go index c1236a9cda5..1a0f767f5c7 100644 --- a/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/cmd.go +++ b/staging/src/k8s.io/code-generator/cmd/go-to-protobuf/protobuf/cmd.go @@ -50,7 +50,6 @@ type Generator struct { KeepGogoproto bool SkipGeneratedRewrite bool DropEmbeddedFields string - TrimPathPrefix string } func New() *Generator { @@ -94,7 +93,6 @@ func (g *Generator) BindFlags(flag *flag.FlagSet) { flag.BoolVar(&g.KeepGogoproto, "keep-gogoproto", g.KeepGogoproto, "If true, the generated IDL will contain gogoprotobuf extensions which are normally removed") flag.BoolVar(&g.SkipGeneratedRewrite, "skip-generated-rewrite", g.SkipGeneratedRewrite, "If true, skip fixing up the generated.pb.go file (debugging only).") flag.StringVar(&g.DropEmbeddedFields, "drop-embedded-fields", g.DropEmbeddedFields, "Comma-delimited list of embedded Go types to omit from generated protobufs") - flag.StringVar(&g.TrimPathPrefix, "trim-path-prefix", g.TrimPathPrefix, "If set, trim the specified prefix from --output-package when generating files.") } // This roughly models gengo/v2/args.GeneratorArgs.Execute. @@ -171,7 +169,6 @@ func Run(g *Generator) { c.Verify = g.Common.VerifyOnly c.FileTypes["protoidl"] = NewProtoFile() - c.TrimPathPrefix = g.TrimPathPrefix // Roughly models gengo/v2/args.GeneratorArgs.Execute calling the // tool-provided Packages() callback. @@ -310,22 +307,6 @@ func Run(g *Generator) { outputPath = filepath.Join(g.VendorOutputBase, p.OutputPath()) } - // When working outside of GOPATH, we typically won't want to generate the - // full path for a package. For example, if our current project's root/base - // package is github.com/foo/bar, outDir=., p.Path()=github.com/foo/bar/generated, - // then we really want to be writing files to ./generated, not ./github.com/foo/bar/generated. - // The following will trim a path prefix (github.com/foo/bar) from p.Path() to arrive at - // a relative path that works with projects not in GOPATH. - if g.TrimPathPrefix != "" { - separator := string(filepath.Separator) - if !strings.HasSuffix(g.TrimPathPrefix, separator) { - g.TrimPathPrefix += separator - } - - path = strings.TrimPrefix(path, g.TrimPathPrefix) - outputPath = strings.TrimPrefix(outputPath, g.TrimPathPrefix) - } - // generate the gogoprotobuf protoc cmd := exec.Command("protoc", append(args, path)...) out, err := cmd.CombinedOutput()