Files
threshold/Makefile
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

386 lines
15 KiB
Makefile
Raw Normal View History

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))
THIS_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
2020-04-08 14:55:40 -04: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
2023-02-23 14:58:40 -05:00
TEST_PACKAGE ?= ./...
TEST_TIMEOUT ?= 30m
CGO_ENABLED?=0
2022-12-13 12:07:18 -05:00
GO_PATH = $(shell go env GOPATH)
export GEN_BASEPATH := $(shell pwd)
2020-05-04 11:23:35 -04:00
.PHONY: api
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
.PHONY: cli
2021-02-23 19:06:39 -05:00
cli:
$(MAKE) --environment-overrides -C internal/cmd/gencli cli
.PHONY: tools
2022-12-13 12:07:18 -05:00
tools: golangci-lint
2020-05-01 12:38:01 -07:00
go generate -tags tools tools/tools.go
go install github.com/bufbuild/buf/cmd/buf@v1.15.1
go install github.com/mfridman/tparse@v0.10.3
2023-02-02 17:15:05 -08:00
go install github.com/hashicorp/copywrite@v0.15.0
2020-05-01 12:38:01 -07:00
2022-12-13 12:07:18 -05:00
# golangci-lint recommends installing the binary directly, instead of using go get
# See the note: https://golangci-lint.run/usage/install/#install-from-source
.PHONY: golangci-lint
golangci-lint:
$(eval GOLINT_INSTALLED := $(shell which golangci-lint))
if [ "$(GOLINT_INSTALLED)" = "" ]; then \
2023-03-07 16:29:34 -05:00
sh scripts/install-golangci-lint.sh -b $(GO_PATH)/bin v1.51.2; \
2022-12-13 12:07:18 -05:00
fi;
.PHONY: cleangen
cleangen:
@rm -f $(shell find ${THIS_DIR} -name '*.gen.go' && find ${THIS_DIR} -name '*.pb.go' && find ${THIS_DIR} -name '*.pb.gw.go')
2020-05-04 14:58:18 -04:00
.PHONY: dev
2022-03-09 16:20:44 -05:00
dev:
@echo "This command has changed. Please use:"
@echo "==> make build"
@echo " to build the binary into the bin/ directory"
@echo "==> make install"
@echo " to build the binary and install it into GOPATH/bin"
.PHONY: build
build: BUILD_TAGS+=ui
build: build-ui-ifne
@echo "==> Building Boundary with UI features enabled"
2020-09-25 17:44:50 -04:00
@CGO_ENABLED=$(CGO_ENABLED) BUILD_TAGS='$(BUILD_TAGS)' sh -c "'$(CURDIR)/scripts/build.sh'"
2022-03-09 16:20:44 -05:00
.PHONY: install
install: export BOUNDARY_INSTALL_BINARY=1
install: build
2023-03-07 16:29:34 -05:00
.PHONY: install-no-plugins
install-no-plugins: export SKIP_PLUGIN_BUILD=1
install-no-plugins: install
2022-05-09 10:16:10 -04:00
.PHONY: build-memprof
build-memprof: BUILD_TAGS+=memprofiler
build-memprof:
@echo "==> Building Boundary with memory profiling enabled"
@CGO_ENABLED=$(CGO_ENABLED) BUILD_TAGS='$(BUILD_TAGS)' sh -c "'$(CURDIR)/scripts/build.sh'"
2022-03-29 15:37:25 -04:00
# Format Go files, ignoring files marked as generated through the header defined at
# https://pkg.go.dev/cmd/go#hdr-Generate_Go_files_by_processing_source
.PHONY: fmt
2020-08-12 00:40:39 -04:00
fmt:
2022-03-29 15:37:25 -04:00
grep -L -R "^\/\/ Code generated .* DO NOT EDIT\.$$" --exclude-dir=.git --include="*.go" . | xargs gofumpt -w
buf format -w
2020-08-12 00:40:39 -04:00
2022-12-13 12:07:18 -05:00
lint:
golangci-lint run --timeout 10m
ifndef LINT_DIFF_BRANCH
override LINT_DIFF_BRANCH = main
endif
lint-diff:
@echo "Checking for lint compared to $(LINT_DIFF_BRANCH)"
golangci-lint run --timeout 10m --new-from-rev=$(LINT_DIFF_BRANCH)
2020-10-08 18:51:53 +01:00
# Set env for all UI targets.
UI_TARGETS := update-ui-version build-ui build-ui-ifne clean-ui
2020-10-08 18:51:53 +01:00
# 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_DEFAULT_BRANCH := main
$(UI_TARGETS): export UI_COMMITISH ?=
.PHONY: update-ui-version
2020-10-08 18:51:53 +01:00
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/uiupdate.sh
2020-10-08 18:51:53 +01:00
.PHONY: build-ui
build-ui:
./scripts/build-ui.sh
2023-02-23 14:58:40 -05:00
.PHONY: build-plugins
build-plugins:
@CGO_ENABLED=$(CGO_ENABLED) BUILD_TAGS='$(BUILD_TAGS)' sh -c "'$(CURDIR)/scripts/plugins.sh'"
.PHONY: clean-ui
clean-ui:
rm -rf ${UI_CLONE_DIR}
.PHONY: build-ui-ifne
build-ui-ifne:
ifeq (,$(wildcard internal/ui/.tmp/boundary-ui))
@echo "==> No UI assets found, building..."
2020-10-08 18:51:53 +01:00
@$(MAKE) build-ui
else
@echo "==> UI assets found, use build-ui target to update"
endif
.PHONY: perms-table
perms-table:
@go run internal/website/permstable/permstable.go
.PHONY: gen
2023-02-02 17:15:05 -08:00
gen: cleangen proto api cli perms-table fmt copywrite
### oplog requires protoc-gen-go v1.20.0 or later
# GO111MODULE=on go get -u github.com/golang/protobuf/protoc-gen-go@v1.40
.PHONY: proto
proto: protolint protobuild
2020-04-08 14:55:40 -04:00
.PHONY: protobuild
protobuild:
@buf generate -o "${TMP_DIR}"
# Move the generated files from the tmp file subdirectories into the current repo.
cp -R ${TMP_DIR}/${REPO_PATH}/* ${THIS_DIR}
@buf generate --template buf.openapiv2.gen.yaml --path internal/proto/controller/api/services/v1/
@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
@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
@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
@protoc-go-inject-tag -input=./internal/db/db_test/db_test.pb.go
@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
@protoc-go-inject-tag -input=./internal/host/plugin/store/host.pb.go
@protoc-go-inject-tag -input=./internal/plugin/host/store/plugin.pb.go
@protoc-go-inject-tag -input=./internal/plugin/store/plugin.pb.go
2020-07-07 07:44:49 -07:00
@protoc-go-inject-tag -input=./internal/authtoken/store/authtoken.pb.go
@protoc-go-inject-tag -input=./internal/auth/store/account.pb.go
@protoc-go-inject-tag -input=./internal/auth/password/store/password.pb.go
@protoc-go-inject-tag -input=./internal/auth/password/store/argon2.pb.go
@protoc-go-inject-tag -input=./internal/kms/store/root_key.pb.go
@protoc-go-inject-tag -input=./internal/kms/store/database_key.pb.go
@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
@protoc-go-inject-tag -input=./internal/kms/store/oidc_key.pb.go
2022-11-16 17:17:28 -06:00
@protoc-go-inject-tag -input=./internal/kms/store/data_key_version_destruction_job.pb.go
@protoc-go-inject-tag -input=./internal/kms/store/data_key_version_destruction_job_run.pb.go
@protoc-go-inject-tag -input=./internal/kms/store/data_key_version_destruction_job_progress.pb.go
@protoc-go-inject-tag -input=./internal/kms/store/data_key_version_destruction_job_run_allowed_table_name.pb.go
2022-06-20 18:20:17 -07:00
@protoc-go-inject-tag -input=./internal/server/store/controller.pb.go
@protoc-go-inject-tag -input=./internal/server/store/worker.pb.go
@protoc-go-inject-tag -input=./internal/server/store/root_certificate.pb.go
@protoc-go-inject-tag -input=./internal/server/store/worker_auth.pb.go
2020-08-26 13:58:46 -04:00
@protoc-go-inject-tag -input=./internal/target/store/target.pb.go
@protoc-go-inject-tag -input=./internal/target/targettest/store/target.pb.go
2021-09-29 13:13:49 -04:00
@protoc-go-inject-tag -input=./internal/target/tcp/store/target.pb.go
2021-04-08 20:54:32 -04:00
@protoc-go-inject-tag -input=./internal/auth/oidc/store/oidc.pb.go
2021-05-06 14:54:10 -07:00
@protoc-go-inject-tag -input=./internal/scheduler/job/store/job.pb.go
@protoc-go-inject-tag -input=./internal/credential/store/credential.pb.go
@protoc-go-inject-tag -input=./internal/credential/vault/store/vault.pb.go
@protoc-go-inject-tag -input=./internal/credential/static/store/static.pb.go
@protoc-go-inject-tag -input=./internal/kms/store/audit_key.pb.go
@protoc-go-inject-tag -input=./internal/auth/ldap/store/ldap.pb.go
2020-08-26 13:58:46 -04:00
# inject classification tags (see: https://github.com/hashicorp/go-eventlogger/tree/main/filters/encrypt)
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/auth_method_service.pb.go
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/authmethods/auth_method.pb.go
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/scopes/scope.pb.go
2022-11-16 17:17:28 -06:00
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/scope_service.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/servers/services/session_service.pb.go
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/targets/target.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/target_service.pb.go
2022-03-29 17:42:23 -04:00
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/accounts/account.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/account_service.pb.go
2022-04-13 12:56:31 -04:00
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/hosts/host.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/host_service.pb.go
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/plugins/plugin.pb.go
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/hostcatalogs/host_catalog.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/host_catalog_service.pb.go
2022-04-13 12:58:33 -04:00
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/hostsets/host_set.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/host_set_service.pb.go
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/authtokens/authtoken.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/authtokens_service.pb.go
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/managedgroups/managed_group.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/managed_group_service.pb.go
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/groups/group.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/group_service.pb.go
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/credentialstores/credential_store.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/credential_store_service.pb.go
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/credentiallibraries/credential_library.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/credential_library_service.pb.go
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/credentials/credential.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/credential_service.pb.go
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/roles/role.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/role_service.pb.go
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/sessions/session.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/session_service.pb.go
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/users/user.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/user_service.pb.go
@protoc-go-inject-tag -input=./sdk/pbs/controller/api/resources/workers/worker.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/api/services/worker_service.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/servers/services/server_coordination_service.pb.go
@protoc-go-inject-tag -input=./internal/gen/controller/servers/servers.pb.go
2020-08-26 13:58:46 -04:00
# these protos, services and openapi artifacts are purely for testing purposes
@protoc-go-inject-tag -input=./internal/gen/testing/event/event.pb.go
@buf generate --template buf.testing.gen.yaml --path internal/proto/testing/event/v1/
@rm -R ${TMP_DIR}
.PHONY: protolint
protolint:
@buf lint
# First check all protos except controller/servers and controller/storage for WIRE_JSON compatibility
cd internal/proto && buf breaking --against 'https://github.com/hashicorp/boundary.git#branch=stable-website,subdir=internal/proto' \
--exclude-path=controller/servers \
--exclude-path=controller/storage \
--config buf.breaking.json.yaml
# Next check all protos for WIRE compatibility. WIRE is a subset of WIRE_JSON so we don't need to exclude any files.
cd internal/proto && buf breaking --against 'https://github.com/hashicorp/boundary.git#branch=stable-website,subdir=internal/proto' \
--config buf.breaking.wire.yaml
2023-02-02 17:15:05 -08:00
.PHONY: copywrite
copywrite:
copywrite headers
.PHONY: website
# must have nodejs and npm installed
website: website-install website-start
.PHONY: website-install
website-install:
@npm install --prefix website/
.PHONY: website-start
website-start:
@npm start --prefix website/
.PHONY: test-database-up
test-database-up:
make -C testing/dbtest/docker database-up
.PHONY: test-database-down
test-database-down:
make -C testing/dbtest/docker clean
2022-04-25 16:11:27 -04:00
.PHONY: generate-database-dumps
generate-database-dumps:
@$(MAKE) -C testing/dbtest/docker generate-database-dumps
.PHONY: test-sql
test-sql:
$(MAKE) -C internal/db/sqltest/ test
.PHONY: test
test:
2023-03-07 16:29:34 -05:00
go test "$(TEST_PACKAGE)" -tags="$(BUILD_TAGS)" $(TESTARGS) -json -cover -timeout $(TEST_TIMEOUT) | tparse -follow
2021-12-01 18:57:03 -05:00
.PHONY: test-sdk
test-sdk:
$(MAKE) -C sdk/ test
.PHONY: test-api
test-api:
$(MAKE) -C api/ test
.PHONY: test-cli
test-cli:
$(MAKE) -C internal/tests/cli test
2021-12-01 18:57:03 -05:00
.PHONY: test-all
test-all: test-sdk test-api test
2022-04-25 16:07:46 -04:00
BENCH_TIME?=1s
BENCH_COUNT?=1s
.PHONY: benchmark
benchmark:
@go test \
-timeout 60m \
./internal/servers/controller/handlers/sessions/ \
-v \
-bench '^BenchmarkSessionList$$' \
-benchtime $(BENCH_TIME) \
-count $(BENCH_COUNT) \
-run '^$$'
.PHONY: install-go
install-go:
./ci/goinstall.sh
# Docker build and publish variables and targets
REGISTRY_NAME?=docker.io/hashicorp
IMAGE_NAME=boundary
VERSION?=0.7.4
IMAGE_TAG=$(REGISTRY_NAME)/$(IMAGE_NAME):$(VERSION)
IMAGE_TAG_DEV?=$(REGISTRY_NAME)/$(IMAGE_NAME):latest-$(shell git rev-parse --short HEAD)
.PHONY: docker
2022-02-01 07:41:27 -08:00
docker: docker-build
.PHONY: docker-build
2022-02-01 07:41:27 -08:00
# Builds from the releases.hashicorp.com official binary
docker-build:
2022-02-01 07:41:27 -08:00
docker build \
--tag $(IMAGE_TAG) \
--tag hashicorp/boundary:latest \
--target=official \
--build-arg VERSION=$(VERSION) \
.
.PHONY: docker-multiarch-build
2022-02-01 07:41:27 -08:00
# Builds multiarch from the releases.hashicorp.com official binary
docker-multiarch-build:
docker buildx build \
2022-02-01 07:41:27 -08:00
--tag $(IMAGE_TAG) \
--tag hashicorp/boundary:latest \
--target=official \
--build-arg VERSION=$(VERSION) \
--platform linux/amd64,linux/arm64 \
.
2021-09-21 09:46:17 -04:00
DEV_DOCKER_GOOS ?= linux
DEV_DOCKER_GOARCH ?= amd64
.PHONY: docker-build-dev
2022-02-01 07:41:27 -08:00
# Builds from the locally generated binary in ./bin/
docker-build-dev: export GOOS=$(DEV_DOCKER_GOOS)
docker-build-dev: export GOARCH=$(DEV_DOCKER_GOARCH)
docker-build-dev: build
docker buildx build \
--load \
--platform $(DEV_DOCKER_GOOS)/$(DEV_DOCKER_GOARCH) \
2022-02-01 07:41:27 -08:00
--tag $(IMAGE_TAG_DEV) \
--target=dev \
--build-arg=boundary \
.
@echo "Successfully built $(IMAGE_TAG_DEV)"
.NOTPARALLEL:
2020-09-28 17:15:28 +01:00
2022-02-01 07:41:27 -08:00
.PHONY: version
# This is used for release builds by .github/workflows/build.yml
version:
@go run ./cmd/boundary version | awk '/Version Number:/ { print $$3 }'
EDITION?=
.PHONY: edition
# This is used for release builds by .github/workflows/build.yml
edition:
@if [ -z "$(EDITION)" ]; then \
go run ./cmd/boundary version -format=json | jq -r '.version_metadata // "oss"'; \
else \
echo $(EDITION); \
fi; \