From 16931138e7c7e4e63286c6bb56dd0d2fe4ad9d63 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 28 Jan 2022 14:43:00 -0800 Subject: [PATCH] Update git submodule location Having the modules stored in `./vendor` causes issues with `go mod`. Follow waypoint's convention to store in `./thirdparty` and grab the same Makefile modifications to alert when the submodules need to be initialized. Update generators to use new path. --- .gitmodules | 2 +- Makefile | 5 ++++- gen.go | 9 ++++++--- internal/cli/base.go | 10 +++++++--- thirdparty/proto/api-common-protos | 1 + 5 files changed, 19 insertions(+), 8 deletions(-) create mode 160000 thirdparty/proto/api-common-protos diff --git a/.gitmodules b/.gitmodules index d622390bd..57415e582 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "thirdparty/proto/api-common-protos"] +[submodule "api-common-protos"] path = thirdparty/proto/api-common-protos url = https://github.com/googleapis/api-common-protos diff --git a/Makefile b/Makefile index 5cda1c846..489611bab 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ CGO_ENABLED?=0 .PHONY: bin bin: # bin creates the binaries for Vagrant for the current platform + @test -s "thirdparty/proto/api-common-protos/.git" || { echo "git submodules not initialized, run 'git submodule update --init --recursive' and try again"; exit 1; } CGO_ENABLED=$(CGO_ENABLED) go build -ldflags $(GOLDFLAGS) -tags assetsembedded -o ./vagrant ./cmd/vagrant .PHONY: bin/windows @@ -21,10 +22,12 @@ bin/windows: # create windows binaries .PHONY: bin/linux bin/linux: # create Linux binaries + @test -s "thirdparty/proto/api-common-protos/.git" || { echo "git submodules not initialized, run 'git submodule update --init --recursive' and try again"; exit 1; } GOOS=linux GOARCH=amd64 $(MAKE) bin .PHONY: bin/darwin bin/darwin: # create Darwin binaries + @test -s "thirdparty/proto/api-common-protos/.git" || { echo "git submodules not initialized, run 'git submodule update --init --recursive' and try again"; exit 1; } GOOS=darwin GOARCH=amd64 $(MAKE) bin .PHONY: test @@ -53,6 +56,6 @@ static-assets: gen/doc: @rm -rf ./doc/* 2> /dev/null protoc -I=. \ - -I=./vendor/proto/api-common-protos/ \ + -I=./thirdparty/proto/api-common-protos/ \ --doc_out=./doc --doc_opt=html,index.html \ ./internal/server/proto/server.proto diff --git a/gen.go b/gen.go index 2d1cd5eff..11a625223 100644 --- a/gen.go +++ b/gen.go @@ -5,13 +5,16 @@ package main // and installed in the correct locations // Builds the Vagrant server Go GRPC -//go:generate sh -c "protoc -I`go list -m -f \"{{.Dir}}\" github.com/mitchellh/protostructure` -I`go list -m -f \"{{.Dir}}\" github.com/hashicorp/vagrant-plugin-sdk`/proto/vagrant_plugin_sdk -I./vendor/proto/api-common-protos -I./internal/server --go-grpc_out=require_unimplemented_servers=false:./internal/server/proto/vagrant_server --go-grpc_opt=module=github.com/hashicorp/vagrant/internal/server/proto/vagrant_server --go_out=./internal/server/proto/vagrant_server --go_opt=module=github.com/hashicorp/vagrant/internal/server/proto/vagrant_server internal/server/proto/vagrant_server/*.proto" +//go:generate sh -c "protoc -I`go list -m -f \"{{.Dir}}\" github.com/mitchellh/protostructure` -I`go list -m -f \"{{.Dir}}\" github.com/hashicorp/vagrant-plugin-sdk`/proto/vagrant_plugin_sdk -I./thirdparty/proto/api-common-protos -I./internal/server --go-grpc_out=require_unimplemented_servers=false:./internal/server/proto/vagrant_server --go-grpc_opt=module=github.com/hashicorp/vagrant/internal/server/proto/vagrant_server --go_out=./internal/server/proto/vagrant_server --go_opt=module=github.com/hashicorp/vagrant/internal/server/proto/vagrant_server internal/server/proto/vagrant_server/*.proto" // Builds the Ruby Vagrant Go GRPC for legacy Vagrant interactions -//go:generate sh -c "protoc -I./vendor/proto/api-common-protos -I./internal/server -I`go list -m -f \"{{.Dir}}\" github.com/mitchellh/protostructure` -I`go list -m -f \"{{.Dir}}\" github.com/hashicorp/vagrant-plugin-sdk`/proto/vagrant_plugin_sdk --go-grpc_out=./internal/server/proto/ruby_vagrant --go-grpc_opt=module=github.com/hashicorp/vagrant/internal/server/proto/ruby_vagrant --go_out=./internal/server/proto/ruby_vagrant --go_opt=module=github.com/hashicorp/vagrant/internal/server/proto/ruby_vagrant internal/server/proto/ruby_vagrant/*.proto" +//go:generate sh -c "protoc -I./thirdparty/proto/api-common-protos -I./internal/server -I`go list -m -f \"{{.Dir}}\" github.com/mitchellh/protostructure` -I`go list -m -f \"{{.Dir}}\" github.com/hashicorp/vagrant-plugin-sdk`/proto/vagrant_plugin_sdk --go-grpc_out=./internal/server/proto/ruby_vagrant --go-grpc_opt=module=github.com/hashicorp/vagrant/internal/server/proto/ruby_vagrant --go_out=./internal/server/proto/ruby_vagrant --go_opt=module=github.com/hashicorp/vagrant/internal/server/proto/ruby_vagrant internal/server/proto/ruby_vagrant/*.proto" // Builds the Ruby GRPC for the Vagrant server and Ruby Vagrant interactions -//go:generate sh -c "grpc_tools_ruby_protoc -I`go list -m -f \"{{.Dir}}\" github.com/mitchellh/protostructure` -I`go list -m -f \"{{.Dir}}\" github.com/hashicorp/vagrant-plugin-sdk`/proto/vagrant_plugin_sdk -I./vendor/proto/api-common-protos -I./internal/server --grpc_out=./lib/vagrant/protobufs/ --ruby_out=./lib/vagrant/protobufs/ internal/server/proto/vagrant_server/*.proto internal/server/proto/ruby_vagrant/*.proto" +//go:generate sh -c "grpc_tools_ruby_protoc -I`go list -m -f \"{{.Dir}}\" github.com/mitchellh/protostructure` -I`go list -m -f \"{{.Dir}}\" github.com/hashicorp/vagrant-plugin-sdk`/proto/vagrant_plugin_sdk -I./thirdparty/proto/api-common-protos -I./internal/server --grpc_out=./lib/vagrant/protobufs/ --ruby_out=./lib/vagrant/protobufs/ internal/server/proto/vagrant_server/*.proto internal/server/proto/ruby_vagrant/*.proto" // Builds the Ruby GRPC for the Vagrant Plugin SDK //go:generate sh -c "grpc_tools_ruby_protoc -I`go list -m -f \"{{.Dir}}\" github.com/hashicorp/vagrant-plugin-sdk`/proto -I`go list -m -f \"{{.Dir}}\" github.com/mitchellh/protostructure` -I`go list -m -f \"{{.Dir}}\" github.com/hashicorp/vagrant-plugin-sdk`/3rdparty/proto/api-common-protos -I`go list -m -f \"{{.Dir}}\" github.com/hashicorp/go-plugin`/internal --grpc_out=./lib/vagrant/protobufs/proto/ --ruby_out=./lib/vagrant/protobufs/proto/ plugin/grpc_broker.proto vagrant_plugin_sdk/plugin.proto protostructure.proto" + +// Generate strings for flag types +//go:generate stringer -type=Type -linecomment ./internal/flags diff --git a/internal/cli/base.go b/internal/cli/base.go index fb56a58f4..441ce6ab7 100644 --- a/internal/cli/base.go +++ b/internal/cli/base.go @@ -416,17 +416,20 @@ func (c *baseCommand) flagSet(bit flagSetBit, f func([]*component.CommandFlag) [ set = append(set, &component.CommandFlag{ LongName: "server-addr", + ShortName: "", Description: "Address for the server", Type: component.FlagString, }, &component.CommandFlag{ LongName: "server-tls", + ShortName: "", Description: "Connect to server via TLS", DefaultValue: "true", Type: component.FlagBool, }, &component.CommandFlag{ LongName: "server-tls-skip-verify", + ShortName: "", Description: "Skip verification of the TLS certificate advertised by the server", DefaultValue: "false", Type: component.FlagBool, @@ -453,6 +456,7 @@ func (c *baseCommand) Parse( } else { opt.SetUnknownMode(getoptions.Fail) } + opt.SetMode(getoptions.Bundling) c.Log.Warn("parsing arguments with flags", "args", args, "flags", flags) remainArgs, err := opt.Parse(args) @@ -489,9 +493,9 @@ func (c *baseCommand) generateCliFlags(set []*component.CommandFlag) *getoptions if f.Description != "" { opts = append(opts, opt.Description(f.Description)) } - if f.ShortName != "" { - opts = append(opts, opt.Alias(f.ShortName)) - } + // if f.ShortName != "" { + // opts = append(opts, opt.Alias(f.ShortName)) + // } switch f.Type { case component.FlagBool: diff --git a/thirdparty/proto/api-common-protos b/thirdparty/proto/api-common-protos new file mode 160000 index 000000000..e16c55b09 --- /dev/null +++ b/thirdparty/proto/api-common-protos @@ -0,0 +1 @@ +Subproject commit e16c55b094638b43a97edd0847614ab91e2461f7