Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(containeranalysis): move grafeas stubs to proper folder #6732

Merged
merged 4 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions internal/gapicgen/generator/gapics.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,19 +327,28 @@ func (g *GapicGenerator) microgen(conf *MicrogenConfig) error {
// override the go_package option. Applied to both the protobuf/gRPC
// generated code, and to notify the GAPIC generator of the new
// import path used to reference those stubs.
stubPkg := filepath.Join(conf.ImportPath, stubsDir)
stubPkgPath := filepath.Join(conf.ImportPath, stubsDir)
for _, f := range protoFiles {
f = strings.TrimPrefix(f, g.googleapisDir+"/")
// Storage is a special case because it is generating a hidden beta
// proto surface.
if conf.ImportPath == "cloud.google.com/go/storage/internal/apiv2" {
rerouteGoPkg := fmt.Sprintf("M%s=%s;%s", f, stubPkg, conf.Pkg)
rerouteGoPkg := fmt.Sprintf("M%s=%s;%s", f, stubPkgPath, conf.Pkg)
args = append(args,
"--go_opt="+rerouteGoPkg,
"--go_gapic_opt="+rerouteGoPkg,
)
} else {
rerouteGoPkg := fmt.Sprintf("M%s=%s;%s", f, stubPkg, conf.Pkg+"pb")
var stubPkg string
// grafeas is a special case since protos are not at the root of
// client definition
if conf.InputDirectoryPath == "google/devtools/containeranalysis/v1beta1/grafeas" {
stubPkgPath = "cloud.google.com/go/containeranalysis/apiv1beta1/grafeas/grafeaspb"
stubPkg = "grafeaspb"
} else {
stubPkg = conf.Pkg + "pb"
}
rerouteGoPkg := fmt.Sprintf("M%s=%s;%s", f, stubPkgPath, stubPkg)
args = append(args, "--go_opt="+rerouteGoPkg)
if conf.isMigrated() {
args = append(args, "--go_gapic_opt="+rerouteGoPkg)
Expand Down