Skip to content

Commit

Permalink
golang: allow downloads during instalation of gRPC protobuf plugins (#…
Browse files Browse the repository at this point in the history
…21614)

As described in #21529, the Go
rules are setting `GOPROXY=off` during the invocations of `go install`
to install the gRPC protobuf plugins because that is the default for
`GoSdkProcess`. The plugin builds are failing because `GOPROXY=off`
prevents `go` from contacting the Go module proxy to learn about module
deprecations. (Unlike other uses of `GoSdkProcess`, the gRPC protobuf
plugins are relying on `go install` to do a full build of the plugin
sources, which is unlike the use of `GoSdkProcess` in the rest of the Go
backend rules.)

Solution: Set `allow_downloads=True` (which is already done for a
preceding `go mod download`) to allow `go` to contact the Go module
proxy as needed by not setting `GOPROXY=off`.

Fixes #21529.
  • Loading branch information
tdyas authored Jan 19, 2025
1 parent 305a9cb commit 908d348
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/notes/2.25.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ The default version of the [Pex](https://docs.pex-tool.org/) tool has been updat

The `pants.backend.experimental.python.lint.ruff.check` backend [now supports](https://github.com/pantsbuild/pants/pull/21783) including [Ruff's output file as a report](https://www.pantsbuild.org/2.25/docs/python/overview/linters-and-formatters#bandit-flake8-pylint-and-ruff-report-files).

#### Go

Fix a bug with the setup of the gRPC protobuf plugins where a `go install` invocation was prevented from accessing the Go module proxy during its build of those plugins, which caused those builds to fail.


##### NEW: Python for OpenAPI

A new experimental `pants.backend.experimental.openapi.codegen.python` backend
Expand Down
4 changes: 4 additions & 0 deletions src/python/pants/backend/codegen/protobuf/go/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ async def setup_go_protoc_plugin() -> _SetupGoProtocPlugin:
input_digest=download_sources_result.output_digest,
output_files=["gopath/bin/protoc-gen-go"],
description="Build Go protobuf plugin for `protoc`.",
# Allow `go` to contact the Go module proxy since it will run its own build.
allow_downloads=True,
),
),
Get(
Expand All @@ -611,6 +613,8 @@ async def setup_go_protoc_plugin() -> _SetupGoProtocPlugin:
input_digest=download_sources_result.output_digest,
output_files=["gopath/bin/protoc-gen-go-grpc"],
description="Build Go gRPC protobuf plugin for `protoc`.",
# Allow `go` to contact the Go module proxy since it will run its own build.
allow_downloads=True,
),
),
)
Expand Down

0 comments on commit 908d348

Please sign in to comment.