Skip to content

Commit

Permalink
protos: Update .proto files not to use Go package name (#9301)
Browse files Browse the repository at this point in the history
Previously, it was required that you `go get github.com/hashicorp/nomad` to be
able to build protos, as the protoc invocation added an include directive that
pointed to `$GOPATH/src`, which is how dependent protos were discovered. As
Nomad now uses Go modules, it won't necessarily be cloned to `$GOPATH`.
(Additionally, if you _had_ go-gotten Nomad at some point, protoc compilation
would have possibly used the _wrong_ protos, as those wouldn't necessarily be
the most up-to-date ones.)

This change modifies the proto files and the `protoc` invocation to handle
discovering dependent protos via protoc plugin modifier statements that are
specific to the protoc plugin being used.

In this change, `make proto` was run to recompile the protos, which results in
changes only to the gzipped `FileDescriptorProto`.
  • Loading branch information
Kris Hicks authored Nov 10, 2020
1 parent b312aac commit b3825e7
Show file tree
Hide file tree
Showing 9 changed files with 402 additions and 396 deletions.
12 changes: 11 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,21 @@ generate-structs: ## Update generated code
@echo "--> Running go generate..."
@go generate $(LOCAL_PACKAGES)

## The ",M<path/to/proto>=<package name>" below is required to tell
## protoc-gen-go what the import path for a given proto file should be. This is
## necessary when a proto file foo/a.proto imports a proto file from another
## directory, e.g. bar/b.proto
.PHONY: proto
proto:
@echo "--> Generating proto bindings..."
@for file in $$(git ls-files "*.proto" | grep -E -v -- "vendor\/.*.proto|demo\/.*.proto"); do \
protoc -I . -I $(shell go env GOPATH)/src --go_out=plugins=grpc:. $$file; \
protoc -I . --go_out=plugins=grpc\
,Mplugins/shared/hclspec/hcl_spec.proto=github.com/hashicorp/nomad/plugins/shared/hclspec\
,Mplugins/shared/structs/proto/stats.proto=github.com/hashicorp/nomad/plugins/shared/structs/proto\
,Mplugins/shared/structs/proto/attribute.proto=github.com/hashicorp/nomad/plugins/shared/structs/proto\
,Mplugins/shared/structs/proto/recoverable_error.proto=github.com/hashicorp/nomad/plugins/shared/structs/proto\
,Mplugins/drivers/proto/driver.proto=github.com/hashicorp/nomad/plugins/drivers/proto\
:. $$file; \
done

.PHONY: generate-examples
Expand Down
125 changes: 62 additions & 63 deletions drivers/shared/executor/proto/executor.pb.go

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

2 changes: 1 addition & 1 deletion drivers/shared/executor/proto/executor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package hashicorp.nomad.plugins.executor.proto;
option go_package = "proto";

import "google/protobuf/timestamp.proto";
import "github.com/hashicorp/nomad/plugins/drivers/proto/driver.proto";
import "plugins/drivers/proto/driver.proto";

service Executor {
rpc Launch(LaunchRequest) returns (LaunchResponse) {}
Expand Down
69 changes: 34 additions & 35 deletions plugins/base/proto/base.pb.go

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

Loading

0 comments on commit b3825e7

Please sign in to comment.