Skip to content

Commit 0162416

Browse files
committed
Use go tool to manage protoc plugins
Avoid any dependency on global GOBIN
1 parent a539b4f commit 0162416

File tree

7 files changed

+22
-48
lines changed

7 files changed

+22
-48
lines changed

.github/workflows/build.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,11 @@ jobs:
1010
name: Build
1111
runs-on: ubuntu-latest
1212
steps:
13-
14-
- name: Set up Go 1.x
15-
uses: actions/setup-go@v3
13+
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-go@v5
1616
with:
17-
go-version: ^1.19
18-
id: go
19-
20-
- name: Check out code into the Go module directory
21-
uses: actions/checkout@v3
17+
go-version-file: go.mod
2218

2319
- name: Build Test
2420
run: |

go.mod

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
module github.com/container-storage-interface/spec
22

3-
go 1.18
3+
go 1.24
4+
5+
tool (
6+
google.golang.org/grpc/cmd/protoc-gen-go-grpc
7+
google.golang.org/protobuf/cmd/protoc-gen-go
8+
)
49

510
require (
611
google.golang.org/grpc v1.57.1
@@ -13,4 +18,5 @@ require (
1318
golang.org/x/sys v0.18.0 // indirect
1419
golang.org/x/text v0.14.0 // indirect
1520
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 // indirect
21+
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0 // indirect
1622
)

go.sum

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg
33
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
44
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
55
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
6+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
67
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
78
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
89
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
@@ -14,8 +15,9 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5 h1:
1415
google.golang.org/genproto/googleapis/rpc v0.0.0-20230803162519-f966b187b2e5/go.mod h1:zBEcrKX2ZOcEkHWxBPAIvYUWOKKMIhYcmNiUIu2ji3I=
1516
google.golang.org/grpc v1.57.1 h1:upNTNqv0ES+2ZOOqACwVtS3Il8M12/+Hz41RCPzAjQg=
1617
google.golang.org/grpc v1.57.1/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo=
18+
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0 h1:rNBFJjBCOgVr9pWD7rs/knKL4FRTKgpZmsRfV214zcA=
19+
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0/go.mod h1:Dk1tviKTvMCz5tvh7t+fh94dhmQVHuCt2OzJB3CTW9Y=
1720
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
1821
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
1922
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
2023
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
21-

lib/go/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
/protoc
2-
/protoc-gen-go
32
/csi.a
43
/.protoc

lib/go/Makefile

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,5 @@
11
all: build
22

3-
########################################################################
4-
## GOLANG ##
5-
########################################################################
6-
7-
# If GOPATH isn't defined then set its default location.
8-
ifeq (,$(strip $(GOPATH)))
9-
GOPATH := $(HOME)/go
10-
else
11-
# If GOPATH is already set then update GOPATH to be its own
12-
# first element.
13-
GOPATH := $(word 1,$(subst :, ,$(GOPATH)))
14-
endif
15-
export GOPATH
16-
17-
GOBIN := $(shell go env GOBIN)
18-
ifeq (,$(strip $(GOBIN)))
19-
GOBIN := $(GOPATH)/bin
20-
endif
21-
22-
233
########################################################################
244
## PROTOC ##
255
########################################################################
@@ -46,28 +26,14 @@ PROTOC_URL := https://github.com/protocolbuffers/protobuf/releases/download/v$(P
4626
PROTOC_TMP_DIR := .protoc
4727
PROTOC := $(PROTOC_TMP_DIR)/bin/protoc
4828

49-
$(GOBIN)/protoc-gen-go: ../../go.mod
50-
go install google.golang.org/protobuf/cmd/protoc-gen-go
51-
$(GOBIN)/protoc-gen-go-grpc:
52-
go install google.golang.org/grpc/cmd/[email protected]
53-
5429
$(PROTOC):
5530
-mkdir -p "$(PROTOC_TMP_DIR)" && \
5631
curl -L $(PROTOC_URL) -o "$(PROTOC_TMP_DIR)/$(PROTOC_ZIP)" && \
5732
unzip "$(PROTOC_TMP_DIR)/$(PROTOC_ZIP)" -d "$(PROTOC_TMP_DIR)" && \
5833
chmod 0755 "$@"
5934
stat "$@" > /dev/null 2>&1
6035

61-
PROTOC_ALL := $(GOBIN)/protoc-gen-go $(GOBIN)/protoc-gen-go-grpc $(PROTOC)
62-
63-
########################################################################
64-
## PATH ##
65-
########################################################################
66-
67-
# Update PATH with GOBIN. This enables the protoc binary to discover
68-
# the protoc-gen-go binary
69-
export PATH := $(GOBIN):$(PATH)
70-
36+
PROTOC_ALL := protoc-gen-go protoc-gen-go-grpc $(PROTOC)
7137

7238
########################################################################
7339
## BUILD ##
@@ -78,9 +44,10 @@ CSI_GO := $(CSI_PKG_SUB)/csi.pb.go
7844
CSI_GRPC := $(CSI_PKG_SUB)/csi_grpc.pb.go
7945

8046
# This recipe generates the go language bindings
81-
$(CSI_GO) $(CSI_GRPC): $(CSI_PROTO) $(PROTOC_ALL)
47+
$(CSI_GO) $(CSI_GRPC): $(CSI_PROTO) $(PROTOC_ALL) ../../go.mod
8248
@mkdir -p "$(@D)"
83-
$(PROTOC) -I../.. --go-grpc_out=$(CSI_PKG_SUB) --go_out=$(CSI_PKG_SUB) \
49+
$(PROTOC) --plugin=./protoc-gen-go --plugin=./protoc-gen-go-grpc \
50+
-I../.. --go-grpc_out=$(CSI_PKG_SUB) --go_out=$(CSI_PKG_SUB) \
8451
--go_opt=paths=source_relative --go-grpc_opt=paths=source_relative \
8552
"$(<F)"
8653

lib/go/protoc-gen-go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
go tool protoc-gen-go "$@"

lib/go/protoc-gen-go-grpc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
go tool protoc-gen-go-grpc "$@"

0 commit comments

Comments
 (0)