2020-04-08 14:55:40 -04:00
|
|
|
# Determine this makefile's path.
|
|
|
|
|
# Be sure to place this BEFORE `include` directives, if any.
|
|
|
|
|
THIS_FILE := $(lastword $(MAKEFILE_LIST))
|
2020-05-19 08:33:19 -07:00
|
|
|
THIS_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
|
2020-04-08 14:55:40 -04:00
|
|
|
|
2020-04-28 11:20:37 -07:00
|
|
|
TMP_DIR := $(shell mktemp -d)
|
2020-08-10 17:15:02 -04:00
|
|
|
REPO_PATH := github.com/hashicorp/boundary
|
2020-04-08 14:55:40 -04:00
|
|
|
|
2020-05-19 08:33:19 -07:00
|
|
|
GENERATED_CODE := $(shell find ${THIS_DIR} -name '*.gen.go' && find ${THIS_DIR} -name '*.pb.go' && find ${THIS_DIR} -name '*.pb.gw.go')
|
|
|
|
|
|
2020-05-21 16:03:21 -04:00
|
|
|
CGO_ENABLED?=0
|
|
|
|
|
|
2020-05-11 12:42:10 -04:00
|
|
|
export GEN_BASEPATH := $(shell pwd)
|
2020-05-04 11:23:35 -04:00
|
|
|
|
2021-01-21 16:27:20 -05:00
|
|
|
api:
|
2020-10-07 14:02:33 -04:00
|
|
|
$(MAKE) --environment-overrides -C internal/api/genapi api
|
2020-05-21 16:03:21 -04:00
|
|
|
|
2020-06-30 11:26:22 -04:00
|
|
|
tools:
|
2020-05-01 12:38:01 -07:00
|
|
|
go generate -tags tools tools/tools.go
|
|
|
|
|
|
2020-05-21 16:03:21 -04:00
|
|
|
cleangen:
|
|
|
|
|
@rm -f ${GENERATED_CODE}
|
2020-05-04 14:58:18 -04:00
|
|
|
|
2020-05-21 16:03:21 -04:00
|
|
|
dev: BUILD_TAGS+=dev
|
2020-07-07 19:57:54 -04:00
|
|
|
dev: BUILD_TAGS+=ui
|
2020-06-30 11:26:22 -04:00
|
|
|
dev: build-ui-ifne
|
2020-08-10 17:15:02 -04:00
|
|
|
@echo "==> Building Boundary with dev and UI features enabled"
|
|
|
|
|
@CGO_ENABLED=$(CGO_ENABLED) BUILD_TAGS='$(BUILD_TAGS)' BOUNDARY_DEV_BUILD=1 sh -c "'$(CURDIR)/scripts/build.sh'"
|
2020-05-21 16:03:21 -04:00
|
|
|
|
2020-09-25 17:44:50 -04:00
|
|
|
bin: BUILD_TAGS+=ui
|
|
|
|
|
bin: build-ui
|
|
|
|
|
@echo "==> Building Boundary with UI features enabled"
|
|
|
|
|
@CGO_ENABLED=$(CGO_ENABLED) BUILD_TAGS='$(BUILD_TAGS)' sh -c "'$(CURDIR)/scripts/build.sh'"
|
|
|
|
|
|
2020-08-12 00:40:39 -04:00
|
|
|
fmt:
|
2021-01-07 10:02:32 -05:00
|
|
|
gofumpt -w $$(find . -name '*.go' | grep -v pb.go | grep -v pb.gw.go)
|
2020-08-12 00:40:39 -04:00
|
|
|
|
2020-10-08 18:51:53 +01:00
|
|
|
# Set env for all UI targets.
|
|
|
|
|
UI_TARGETS := update-ui-version build-ui build-ui-ifne
|
|
|
|
|
# Note the extra .tmp path segment in UI_CLONE_DIR is significant and required.
|
|
|
|
|
$(UI_TARGETS): export UI_CLONE_DIR := internal/ui/.tmp/boundary-ui
|
|
|
|
|
$(UI_TARGETS): export UI_VERSION_FILE := internal/ui/VERSION
|
|
|
|
|
$(UI_TARGETS): export UI_ASSETS_FILE := internal/ui/assets.go
|
|
|
|
|
$(UI_TARGETS): export UI_DEFAULT_BRANCH := main
|
|
|
|
|
$(UI_TARGETS): export UI_CURRENT_COMMIT := $(shell head -n1 < "$(UI_VERSION_FILE)" | cut -d' ' -f1)
|
|
|
|
|
$(UI_TARGETS): export UI_COMMITISH ?=
|
|
|
|
|
|
|
|
|
|
update-ui-version:
|
|
|
|
|
@if [ -z "$(UI_COMMITISH)" ]; then \
|
|
|
|
|
echo "==> Setting UI version to latest commit on branch '$(UI_DEFAULT_BRANCH)'"; \
|
|
|
|
|
export UI_COMMITISH="$(UI_DEFAULT_BRANCH)"; \
|
|
|
|
|
else \
|
|
|
|
|
echo "==> Setting to latest commit matching '$(UI_COMMITISH)'"; \
|
|
|
|
|
fi; \
|
|
|
|
|
./scripts/uiclone.sh && ./scripts/uiupdate.sh
|
|
|
|
|
|
2020-06-30 11:26:22 -04:00
|
|
|
build-ui:
|
2020-10-08 18:51:53 +01:00
|
|
|
@if [ -z "$(UI_COMMITISH)" ]; then \
|
|
|
|
|
echo "==> Building default UI version from $(UI_VERSION_FILE): $(UI_CURRENT_COMMIT)"; \
|
|
|
|
|
export UI_COMMITISH="$(UI_CURRENT_COMMIT)"; \
|
|
|
|
|
else \
|
|
|
|
|
echo "==> Building custom UI version $(UI_COMMITISH)"; \
|
|
|
|
|
fi; \
|
|
|
|
|
./scripts/uiclone.sh && ./scripts/uigen.sh
|
2020-06-30 11:26:22 -04:00
|
|
|
|
|
|
|
|
build-ui-ifne:
|
|
|
|
|
ifeq (,$(wildcard internal/ui/assets.go))
|
|
|
|
|
@echo "==> No UI assets found, building..."
|
2020-10-08 18:51:53 +01:00
|
|
|
@$(MAKE) build-ui
|
2020-06-30 11:26:22 -04:00
|
|
|
else
|
|
|
|
|
@echo "==> UI assets found, use build-ui target to update"
|
|
|
|
|
endif
|
|
|
|
|
|
2020-10-04 21:41:21 -04:00
|
|
|
perms-table:
|
|
|
|
|
@go run internal/website/permstable/permstable.go
|
|
|
|
|
|
2021-01-08 10:32:02 -05:00
|
|
|
gen: cleangen proto api migrations fmt
|
2020-05-04 11:02:02 -04:00
|
|
|
|
2020-05-11 12:42:10 -04:00
|
|
|
migrations:
|
2021-01-19 10:40:41 -07:00
|
|
|
$(MAKE) --environment-overrides -C internal/db/schema/migrations/generate migrations
|
2020-05-11 12:42:10 -04:00
|
|
|
|
2020-04-28 11:20:37 -07:00
|
|
|
### oplog requires protoc-gen-go v1.20.0 or later
|
|
|
|
|
# GO111MODULE=on go get -u github.com/golang/protobuf/protoc-gen-go@v1.40
|
2020-05-19 08:33:19 -07:00
|
|
|
proto: protolint protobuild
|
2020-04-08 14:55:40 -04:00
|
|
|
|
2020-04-28 11:20:37 -07:00
|
|
|
protobuild:
|
2020-05-04 11:23:35 -04:00
|
|
|
# To add a new directory containing a proto pass the proto's root path in
|
|
|
|
|
# through the --proto_path flag.
|
2020-05-21 16:03:21 -04:00
|
|
|
@bash scripts/protoc_gen_plugin.bash \
|
2020-04-28 11:20:37 -07:00
|
|
|
"--proto_path=internal/proto/local" \
|
|
|
|
|
"--proto_include_path=internal/proto/third_party" \
|
|
|
|
|
"--plugin_name=go" \
|
2020-10-09 13:18:53 -04:00
|
|
|
"--plugin_out=${TMP_DIR}"
|
|
|
|
|
@bash scripts/protoc_gen_plugin.bash \
|
|
|
|
|
"--proto_path=internal/proto/local" \
|
|
|
|
|
"--proto_include_path=internal/proto/third_party" \
|
|
|
|
|
"--plugin_name=go-grpc" \
|
|
|
|
|
"--plugin_out=${TMP_DIR}"
|
2020-05-21 16:03:21 -04:00
|
|
|
@bash scripts/protoc_gen_plugin.bash \
|
2020-04-28 11:20:37 -07:00
|
|
|
"--proto_path=internal/proto/local/" \
|
|
|
|
|
"--proto_include_path=internal/proto/third_party" \
|
|
|
|
|
"--plugin_name=grpc-gateway" \
|
|
|
|
|
"--plugin_out=logtostderr=true:${TMP_DIR}"
|
|
|
|
|
|
|
|
|
|
# Move the generated files from the tmp file subdirectories into the current repo.
|
2020-05-19 08:33:19 -07:00
|
|
|
cp -R ${TMP_DIR}/${REPO_PATH}/* ${THIS_DIR}
|
2020-04-28 11:20:37 -07:00
|
|
|
|
2020-07-23 11:26:15 -07:00
|
|
|
@protoc --proto_path=internal/proto/local --proto_path=internal/proto/third_party --openapiv2_out=json_names_for_fields=false,logtostderr=true,disable_default_errors=true,include_package_in_tags=true,fqn_for_openapi_name=true,allow_merge,merge_file_name=controller:internal/gen/. internal/proto/local/controller/api/services/v1/*.proto
|
2020-04-28 11:20:37 -07:00
|
|
|
@protoc-go-inject-tag -input=./internal/oplog/store/oplog.pb.go
|
|
|
|
|
@protoc-go-inject-tag -input=./internal/oplog/oplog_test/oplog_test.pb.go
|
2020-07-10 19:01:23 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/iam/store/group_member.pb.go
|
2020-07-08 17:02:01 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/iam/store/role.pb.go
|
|
|
|
|
@protoc-go-inject-tag -input=./internal/iam/store/principal_role.pb.go
|
2020-07-10 15:46:26 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/iam/store/role_grant.pb.go
|
2020-06-04 20:05:08 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/iam/store/user.pb.go
|
2020-05-08 11:36:28 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/iam/store/scope.pb.go
|
2020-06-11 16:36:47 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/iam/store/group.pb.go
|
2020-05-05 13:29:47 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/db/db_test/db_test.pb.go
|
2020-08-17 11:00:41 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/host/store/host.pb.go
|
2020-05-27 18:16:43 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/host/static/store/static.pb.go
|
2020-07-07 07:44:49 -07:00
|
|
|
@protoc-go-inject-tag -input=./internal/authtoken/store/authtoken.pb.go
|
2020-08-10 15:17:15 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/auth/store/account.pb.go
|
2020-07-24 10:23:35 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/auth/password/store/password.pb.go
|
2020-07-29 07:58:19 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/auth/password/store/argon2.pb.go
|
2020-08-26 13:58:46 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/kms/store/root_key.pb.go
|
2020-09-02 07:42:03 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/kms/store/database_key.pb.go
|
2020-09-02 14:37:19 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/kms/store/oplog_key.pb.go
|
|
|
|
|
@protoc-go-inject-tag -input=./internal/kms/store/token_key.pb.go
|
|
|
|
|
@protoc-go-inject-tag -input=./internal/kms/store/session_key.pb.go
|
2020-08-26 13:58:46 -04:00
|
|
|
@protoc-go-inject-tag -input=./internal/target/store/target.pb.go
|
|
|
|
|
|
2020-04-28 11:20:37 -07:00
|
|
|
@rm -R ${TMP_DIR}
|
|
|
|
|
|
2020-05-21 16:03:21 -04:00
|
|
|
protolint:
|
|
|
|
|
@buf check lint
|
2021-01-20 10:53:01 -05:00
|
|
|
@buf check breaking --against 'https://github.com/hashicorp/boundary.git#branch=stable-website'
|
2020-04-28 11:20:37 -07:00
|
|
|
|
2020-07-24 15:10:34 -07:00
|
|
|
# must have nodejs and npm installed
|
|
|
|
|
website: website-install website-start
|
|
|
|
|
|
|
|
|
|
website-install:
|
|
|
|
|
@npm install --prefix website/
|
|
|
|
|
|
|
|
|
|
website-start:
|
|
|
|
|
@npm start --prefix website/
|
|
|
|
|
|
2020-07-24 20:37:44 -07:00
|
|
|
test-ci: install-go
|
|
|
|
|
~/.go/bin/go test ./... -v $(TESTARGS) -timeout 120m
|
|
|
|
|
|
|
|
|
|
install-go:
|
|
|
|
|
./ci/goinstall.sh
|
2020-07-24 15:10:34 -07:00
|
|
|
|
2020-10-29 08:44:57 -07:00
|
|
|
# Docker build and publish variables and targets
|
|
|
|
|
REGISTRY_NAME?=docker.io/hashicorp
|
|
|
|
|
IMAGE_NAME=boundary
|
2021-01-05 09:26:21 -05:00
|
|
|
VERSION?=0.1.4
|
2020-10-29 08:44:57 -07:00
|
|
|
IMAGE_TAG=$(REGISTRY_NAME)/$(IMAGE_NAME):$(VERSION)
|
|
|
|
|
IMAGE_TAG_DEV=$(REGISTRY_NAME)/$(IMAGE_NAME):latest-$(shell git rev-parse --short HEAD)
|
|
|
|
|
DOCKER_DIR=./docker
|
|
|
|
|
|
|
|
|
|
docker: docker-build docker-publish
|
|
|
|
|
|
|
|
|
|
# builds from releases.hashicorp.com official binary
|
|
|
|
|
docker-build:
|
|
|
|
|
docker build -t $(IMAGE_TAG) \
|
|
|
|
|
--build-arg VERSION=$(VERSION) \
|
|
|
|
|
-f $(DOCKER_DIR)/Release.dockerfile docker/
|
2020-11-19 16:15:19 -08:00
|
|
|
docker tag $(IMAGE_TAG) hashicorp/boundary:latest
|
2020-10-29 08:44:57 -07:00
|
|
|
|
|
|
|
|
# builds from locally generated binary in bin/
|
|
|
|
|
docker-build-dev: export XC_OSARCH=linux/amd64
|
|
|
|
|
docker-build-dev: dev
|
|
|
|
|
docker build -t $(IMAGE_TAG_DEV) \
|
|
|
|
|
-f $(DOCKER_DIR)/Dev.dockerfile .
|
|
|
|
|
|
|
|
|
|
# requires appropriate permissions in dockerhub
|
|
|
|
|
docker-publish:
|
|
|
|
|
docker push $(IMAGE_TAG)
|
2020-11-19 16:15:19 -08:00
|
|
|
docker push hashicorp/boundary:latest
|
2020-10-29 08:44:57 -07:00
|
|
|
|
|
|
|
|
.PHONY: api tools gen migrations proto website ci-config ci-verify set-ui-version docker docker-build docker-build-dev docker-publish
|
2020-04-28 11:20:37 -07:00
|
|
|
|
|
|
|
|
.NOTPARALLEL:
|
2020-09-28 17:15:28 +01:00
|
|
|
|
|
|
|
|
ci-config:
|
|
|
|
|
@$(MAKE) -C .circleci ci-config
|
|
|
|
|
|
|
|
|
|
ci-verify:
|
|
|
|
|
@$(MAKE) -C .circleci ci-verify
|
|
|
|
|
|
|
|
|
|
PACKAGESPEC_CIRCLECI_CONFIG := .circleci/config/@build-release.yml
|
|
|
|
|
PACKAGESPEC_HOOK_POST_CI_CONFIG := $(MAKE) ci-config
|
|
|
|
|
|
|
|
|
|
-include packagespec.mk
|