@@ -127,9 +127,9 @@ test: manifests generate fmt vet envtest ## Run tests.
127127# #@ Protobuf
128128
129129.PHONY : generate-proto
130- generate-proto : # # Generate protobuf and gRPC Go files from occ.proto.
130+ generate-proto : protoc-gen-go protoc-gen-go-grpc # # Generate protobuf and gRPC Go files from occ.proto.
131131 mkdir -p internal/controller/protos/generated
132- protoc --go_out=internal/controller/protos/generated --go_opt=paths=source_relative --go-grpc_out=internal/controller/protos/generated --go-grpc_opt=paths=source_relative -I internal/controller/protos internal/controller/protos/occ.proto
132+ PATH= " $( LOCALBIN ) : $$ PATH " protoc --go_out=internal/controller/protos/generated --go_opt=paths=source_relative --go-grpc_out=internal/controller/protos/generated --go-grpc_opt=paths=source_relative -I internal/controller/protos internal/controller/protos/occ.proto
133133
134134.PHONY : clean-proto
135135clean-proto : # # Remove generated protobuf and gRPC Go files.
@@ -242,10 +242,14 @@ KUBECTL ?= kubectl
242242KUSTOMIZE ?= $(LOCALBIN ) /kustomize
243243CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen
244244ENVTEST ?= $(LOCALBIN ) /setup-envtest
245+ PROTOC_GEN_GO ?= $(LOCALBIN ) /protoc-gen-go
246+ PROTOC_GEN_GO_GRPC ?= $(LOCALBIN ) /protoc-gen-go-grpc
245247
246248# # Tool Versions
247249KUSTOMIZE_VERSION ?= v5.0.1
248250CONTROLLER_TOOLS_VERSION ?= v0.16.5
251+ PROTOC_GEN_GO_VERSION ?= v1.36.11
252+ PROTOC_GEN_GO_GRPC_VERSION ?= v1.6.2
249253
250254.PHONY : kustomize
251255kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
@@ -267,6 +271,18 @@ envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
267271$(ENVTEST ) : $(LOCALBIN )
268272 test -s $(LOCALBIN ) /setup-envtest || GOBIN=$(LOCALBIN ) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
269273
274+ .PHONY : protoc-gen-go
275+ protoc-gen-go : $(PROTOC_GEN_GO ) # # Download protoc-gen-go locally if necessary. If wrong version is installed, it will be overwritten.
276+ $(PROTOC_GEN_GO ) : $(LOCALBIN )
277+ test -s $(LOCALBIN ) /protoc-gen-go && $(LOCALBIN ) /protoc-gen-go --version | grep -q $(PROTOC_GEN_GO_VERSION ) || \
278+ GOBIN=$(LOCALBIN ) go install google.golang.org/protobuf/cmd/protoc-gen-go@$(PROTOC_GEN_GO_VERSION )
279+
280+ .PHONY : protoc-gen-go-grpc
281+ protoc-gen-go-grpc : $(PROTOC_GEN_GO_GRPC ) # # Download protoc-gen-go-grpc locally if necessary. If wrong version is installed, it will be overwritten.
282+ $(PROTOC_GEN_GO_GRPC ) : $(LOCALBIN )
283+ test -s $(LOCALBIN ) /protoc-gen-go-grpc && $(LOCALBIN ) /protoc-gen-go-grpc --version | grep -q $(subst v,,$(PROTOC_GEN_GO_GRPC_VERSION ) ) || \
284+ GOBIN=$(LOCALBIN ) go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@$(PROTOC_GEN_GO_GRPC_VERSION )
285+
270286.PHONY : operator-sdk
271287OPERATOR_SDK ?= $(LOCALBIN ) /operator-sdk
272288operator-sdk : # # Download operator-sdk locally if necessary.
0 commit comments