From abe3ed7d27e3b4bb97a04558273d9152775d7606 Mon Sep 17 00:00:00 2001 From: Jon Poole Date: Wed, 15 Nov 2023 17:06:52 +0000 Subject: [PATCH] Don't leak the proto abstraction --- src/core/BUILD | 2 -- src/core/build_target.go | 7 ------- src/remote/remote.go | 8 +++++++- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/core/BUILD b/src/core/BUILD index 15f5d7efba..0b0b133ccb 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -9,7 +9,6 @@ go_library( pgo_file = "//:pgo", visibility = ["PUBLIC"], deps = [ - "///third_party/go/github.com_bazelbuild_remote-apis//build/bazel/remote/execution/v2", "///third_party/go/github.com_cespare_xxhash_v2//:v2", "///third_party/go/github.com_coreos_go-semver//semver", "///third_party/go/github.com_google_shlex//:shlex", @@ -22,7 +21,6 @@ go_library( "///third_party/go/github.com_thought-machine_go-flags//:go-flags", "///third_party/go/github.com_zeebo_blake3//:blake3", "///third_party/go/golang.org_x_sync//errgroup", - "///third_party/go/google.golang.org_protobuf//proto", "//src/cli", "//src/cli/logging", "//src/cmap", diff --git a/src/core/build_target.go b/src/core/build_target.go index 5f3a4c80a7..f8aa20b131 100644 --- a/src/core/build_target.go +++ b/src/core/build_target.go @@ -10,9 +10,7 @@ import ( "sync/atomic" "time" - pb "github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2" "golang.org/x/sync/errgroup" - "google.golang.org/protobuf/proto" "github.com/thought-machine/please/src/fs" ) @@ -264,11 +262,6 @@ type BuildMetadata struct { Cached bool } -func (m *BuildMetadata) SetRemoteOutputs(tree *pb.Tree) { - data, _ := proto.Marshal(tree) - m.RemoteOutputs = data -} - // A PreBuildFunction is a type that allows hooking a pre-build callback. type PreBuildFunction interface { fmt.Stringer diff --git a/src/remote/remote.go b/src/remote/remote.go index 7d916c2d0d..2a899085aa 100644 --- a/src/remote/remote.go +++ b/src/remote/remote.go @@ -31,6 +31,7 @@ import ( "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/durationpb" "github.com/thought-machine/please/src/cli/logging" @@ -326,7 +327,12 @@ func (c *Client) Build(target *core.BuildTarget) (*core.BuildMetadata, error) { if err != nil { return metadata, c.wrapActionErr(err, digest) } - metadata.SetRemoteOutputs(tree) + + data, err := proto.Marshal(tree) + if err != nil { + return nil, err + } + metadata.RemoteOutputs = data if c.state.ShouldDownload(target) { c.state.LogBuildResult(target, core.TargetBuilding, "Downloading")