From 0f3cb3b35140bdfee88ccc7a77cc925df1652340 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Wed, 29 Apr 2020 13:48:00 -0400 Subject: [PATCH] Add bootstrap target and update how tools are built (#13) * Update tool installation method, add bootstrap target to makefile * Address feedback --- Makefile | 3 +++ tools/tools.go | 40 +++++++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 23dafb464c..bba3a49c6e 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,9 @@ THIS_FILE := $(lastword $(MAKEFILE_LIST)) TMP_DIR := $(shell mktemp -d) REPO_PATH := github.com/hashicorp/watchtower +bootstrap: + go generate -tags tools tools/tools.go + ### oplog requires protoc-gen-go v1.20.0 or later # GO111MODULE=on go get -u github.com/golang/protobuf/protoc-gen-go@v1.40 proto: protolint protobuild cleanup diff --git a/tools/tools.go b/tools/tools.go index ba6893453f..8fe3f1a2fb 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -1,22 +1,32 @@ // +build tools -// This file ensures tool dependencies are kept in sync. This is the recommended way of doing this according to +// This file ensures tool dependencies are kept in sync. This is the +// recommended way of doing this according to // https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module -// To update the versions used by this repo use: -// $ go mod tidy // To install the following tools at the version used by this repo run: -// $ go install (each of the dependencies listed below) +// $ make bootstrap +// or +// $ go generate -tags tools tools/tools.go package tools -import ( - _ "github.com/bufbuild/buf/cmd/buf" - _ "github.com/favadi/protoc-go-inject-tag" - _ "github.com/go-swagger/go-swagger/cmd/swagger" - // use this instead of google.golang.org/protobuf/cmd/protoc-gen-go since this supports grpc plugin while the other does not. - // see https://github.com/golang/protobuf/releases#v1.4-generated-code and - // https://github.com/protocolbuffers/protobuf-go/releases/tag/v1.20.0#v1.20-grpc-support - _ "github.com/golang/protobuf/protoc-gen-go" - _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway" - _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger" -) +//go:generate go install github.com/bufbuild/buf/cmd/buf +import _ "github.com/bufbuild/buf/cmd/buf" + +//go:generate go install github.com/go-swagger/go-swagger/cmd/swagger +import _ "github.com/go-swagger/go-swagger/cmd/swagger" + +//go:generate go install github.com/favadi/protoc-go-inject-tag +import _ "github.com/favadi/protoc-go-inject-tag" + +// use this instead of google.golang.org/protobuf/cmd/protoc-gen-go since this supports grpc plugin while the other does not. +// see https://github.com/golang/protobuf/releases#v1.4-generated-code and +// https://github.com/protocolbuffers/protobuf-go/releases/tag/v1.20.0#v1.20-grpc-support +//go:generate go install github.com/golang/protobuf/protoc-gen-go +import _ "github.com/golang/protobuf/protoc-gen-go" + +//go:generate go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway +import _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway" + +//go:generate go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger +import _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger"