teleport/Makefile

767 lines
24 KiB
Makefile
Raw Normal View History

# Make targets:
#
# all : builds all binaries in development mode, without web assets (default)
# full : builds all binaries for PRODUCTION use
# release: prepares a release tarball
# clean : removes all buld artifacts
# test : runs tests
# To update the Teleport version, update VERSION variable:
# Naming convention:
# Stable releases: "1.0.0"
# Pre-releases: "1.0.0-alpha.1", "1.0.0-beta.2", "1.0.0-rc.3"
# Master/dev branch: "1.0.0-dev"
2021-07-08 20:23:04 +00:00
VERSION=7.0.0-beta.1
2016-06-14 23:52:32 +00:00
DOCKER_IMAGE ?= quay.io/gravitational/teleport
DOCKER_IMAGE_CI ?= quay.io/gravitational/teleport-ci
# These are standard autotools variables, don't change them please
ifneq ("$(wildcard /bin/bash)","")
SHELL := /bin/bash
endif
2016-03-23 01:22:48 +00:00
BUILDDIR ?= build
ASSETS_BUILDDIR ?= lib/web/build
2016-03-24 19:32:59 +00:00
BINDIR ?= /usr/local/bin
DATADIR ?= /usr/local/share/teleport
2016-03-22 19:15:17 +00:00
ADDFLAGS ?=
PWD ?= `pwd`
GOPKGDIR ?= `go env GOPATH`/pkg/`go env GOHOSTOS`_`go env GOARCH`/github.com/gravitational/teleport*
TELEPORT_DEBUG ?= no
GITTAG=v$(VERSION)
BUILDFLAGS ?= $(ADDFLAGS) -ldflags '-w -s'
CGOFLAG ?= CGO_ENABLED=1
# Windows requires extra parameters to cross-compile with CGO.
ifeq ("$(OS)","windows")
BUILDFLAGS = $(ADDFLAGS) -ldflags '-w -s' -buildmode=exe
CGOFLAG = CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++
endif
ifeq ("$(OS)","linux")
# ARM builds need to specify the correct C compiler
ifeq ("$(ARCH)","arm")
CGOFLAG = CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc
endif
# ARM64 builds need to specify the correct C compiler
ifeq ("$(ARCH)","arm64")
CGOFLAG = CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc
endif
endif
OS ?= $(shell go env GOOS)
ARCH ?= $(shell go env GOARCH)
FIPS ?=
RELEASE = teleport-$(GITTAG)-$(OS)-$(ARCH)-bin
# FIPS support must be requested at build time.
FIPS_MESSAGE := "without FIPS support"
ifneq ("$(FIPS)","")
FIPS_TAG := fips
FIPS_MESSAGE := "with FIPS support"
RELEASE = teleport-$(GITTAG)-$(OS)-$(ARCH)-fips-bin
endif
2018-09-27 01:21:45 +00:00
# PAM support will only be built into Teleport if headers exist at build time.
PAM_MESSAGE := "without PAM support"
ifneq ("$(wildcard /usr/include/security/pam_appl.h)","")
PAM_TAG := pam
2018-09-27 01:21:45 +00:00
PAM_MESSAGE := "with PAM support"
else
# PAM headers for Darwin live under /usr/local/include/security instead, as SIP
# prevents us from modifying/creating /usr/include/security on newer versions of MacOS
ifneq ("$(wildcard /usr/local/include/security/pam_appl.h)","")
PAM_TAG := pam
PAM_MESSAGE := "with PAM support"
endif
2018-09-27 01:21:45 +00:00
endif
# BPF support will only be built into Teleport if headers exist at build time.
BPF_MESSAGE := "without BPF support"
# We don't compile BPF for anything except regular non-FIPS linux/amd64 for now, as other builds
# have compilation issues that require fixing.
2021-04-09 23:20:56 +00:00
with_bpf := no
ifeq ("$(OS)","linux")
ifeq ("$(ARCH)","amd64")
2021-04-09 23:20:56 +00:00
ifneq ("$(wildcard /usr/include/bpf/libbpf.h)","")
with_bpf := yes
BPF_TAG := bpf
BPF_MESSAGE := "with BPF support"
2021-04-09 23:20:56 +00:00
CLANG ?= $(shell which clang || which clang-10)
CLANG_FORMAT ?= $(shell which clang-format || which clang-format-10)
LLVM_STRIP ?= $(shell which llvm-strip || which llvm-strip-10)
KERNEL_ARCH := $(shell uname -m | sed 's/x86_64/x86/')
INCLUDES :=
ER_BPF_BUILDDIR := lib/bpf/bytecode
RS_BPF_BUILDDIR := lib/restrictedsession/bytecode
2021-04-09 23:20:56 +00:00
# Get Clang's default includes on this system. We'll explicitly add these dirs
# to the includes list when compiling with `-target bpf` because otherwise some
# architecture-specific dirs will be "missing" on some architectures/distros -
# headers such as asm/types.h, asm/byteorder.h, asm/socket.h, asm/sockios.h,
# sys/cdefs.h etc. might be missing.
#
# Use '-idirafter': Don't interfere with include mechanics except where the
# build would have failed anyways.
CLANG_BPF_SYS_INCLUDES = $(shell $(CLANG) -v -E - </dev/null 2>&1 \
| sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }')
CGOFLAG = CGO_ENABLED=1 CGO_LDFLAGS="-Wl,-Bstatic -lbpf -lelf -lz -Wl,-Bdynamic"
endif
endif
endif
# On Windows only build tsh. On all other platforms build teleport, tctl,
# and tsh.
2018-02-24 01:23:09 +00:00
BINARIES=$(BUILDDIR)/teleport $(BUILDDIR)/tctl $(BUILDDIR)/tsh
RELEASE_MESSAGE := "Building with GOOS=$(OS) GOARCH=$(ARCH) and $(PAM_MESSAGE) and $(FIPS_MESSAGE) and $(BPF_MESSAGE)."
ifeq ("$(OS)","windows")
BINARIES=$(BUILDDIR)/tsh
endif
2021-06-18 18:52:55 +00:00
VERSRC = version.go gitref.go api/version.go
2018-06-15 22:05:15 +00:00
KUBECONFIG ?=
TEST_KUBE ?=
export
2016-01-17 18:28:34 +00:00
#
# 'make all' builds all 3 executables and places them in the current directory.
2018-02-24 01:23:09 +00:00
#
# IMPORTANT: the binaries will not contain the web UI assets and `teleport`
# won't start without setting the environment variable DEBUG=1
# This is the default build target for convenience of working on
# a web UI.
.PHONY: all
2021-06-18 18:52:55 +00:00
all: version
2018-09-27 01:21:45 +00:00
@echo "---> Building OSS binaries."
2018-03-27 17:43:27 +00:00
$(MAKE) $(BINARIES)
# By making these 3 targets below (tsh, tctl and teleport) PHONY we are solving
# several problems:
# * Build will rely on go build internal caching https://golang.org/doc/go1.10 at all times
# * Manual change detection was broken on a large dependency tree
# If you are considering changing this behavior, please consult with dev team first
.PHONY: $(BUILDDIR)/tctl
$(BUILDDIR)/tctl:
GOOS=$(OS) GOARCH=$(ARCH) $(CGOFLAG) go build -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG)" -o $(BUILDDIR)/tctl $(BUILDFLAGS) ./tool/tctl
2018-03-27 17:43:27 +00:00
.PHONY: $(BUILDDIR)/teleport
2021-04-09 23:20:56 +00:00
$(BUILDDIR)/teleport: ensure-webassets bpf-bytecode
GOOS=$(OS) GOARCH=$(ARCH) $(CGOFLAG) go build -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG) $(WEBASSETS_TAG)" -o $(BUILDDIR)/teleport $(BUILDFLAGS) ./tool/teleport
2018-03-27 17:43:27 +00:00
.PHONY: $(BUILDDIR)/tsh
$(BUILDDIR)/tsh:
GOOS=$(OS) GOARCH=$(ARCH) $(CGOFLAG) go build -tags "$(PAM_TAG) $(FIPS_TAG)" -o $(BUILDDIR)/tsh $(BUILDFLAGS) ./tool/tsh
2016-03-22 19:15:17 +00:00
2021-04-09 23:20:56 +00:00
#
# BPF support (IF ENABLED)
# Requires a recent version of clang and libbpf installed.
#
ifeq ("$(with_bpf)","yes")
$(ER_BPF_BUILDDIR):
mkdir -p $(ER_BPF_BUILDDIR)
$(RS_BPF_BUILDDIR):
mkdir -p $(RS_BPF_BUILDDIR)
2021-04-09 23:20:56 +00:00
# Build BPF code
$(ER_BPF_BUILDDIR)/%.bpf.o: bpf/enhancedrecording/%.bpf.c $(wildcard bpf/*.h) | $(ER_BPF_BUILDDIR)
2021-04-09 23:20:56 +00:00
$(CLANG) -g -O2 -target bpf -D__TARGET_ARCH_$(KERNEL_ARCH) $(INCLUDES) $(CLANG_BPF_SYS_INCLUDES) -c $(filter %.c,$^) -o $@
$(LLVM_STRIP) -g $@ # strip useless DWARF info
# Build BPF code
$(RS_BPF_BUILDDIR)/%.bpf.o: bpf/restrictedsession/%.bpf.c $(wildcard bpf/*.h) | $(RS_BPF_BUILDDIR)
$(CLANG) -g -O2 -target bpf -D__TARGET_ARCH_$(KERNEL_ARCH) $(INCLUDES) $(CLANG_BPF_SYS_INCLUDES) -c $(filter %.c,$^) -o $@
$(LLVM_STRIP) -g $@ # strip useless DWARF info
.PHONY: bpf-rs-bytecode
bpf-rs-bytecode: $(RS_BPF_BUILDDIR)/restricted.bpf.o
.PHONY: bpf-er-bytecode
bpf-er-bytecode: $(ER_BPF_BUILDDIR)/command.bpf.o $(ER_BPF_BUILDDIR)/disk.bpf.o $(ER_BPF_BUILDDIR)/network.bpf.o $(ER_BPF_BUILDDIR)/counter_test.bpf.o
2021-04-09 23:20:56 +00:00
.PHONY: bpf-bytecode
bpf-bytecode: bpf-er-bytecode bpf-rs-bytecode
2021-04-09 23:20:56 +00:00
# Generate vmlinux.h based on the installed kernel
.PHONY: update-vmlinux-h
update-vmlinux-h:
bpftool btf dump file /sys/kernel/btf/vmlinux format c >bpf/vmlinux.h
else
.PHONY: bpf-bytecode
bpf-bytecode:
endif
2016-06-14 23:52:32 +00:00
#
# make full - Builds Teleport binaries with the built-in web assets and
# places them into $(BUILDDIR). On Windows, this target is skipped because
# only tsh is built.
#
.PHONY:full
2021-06-28 19:06:47 +00:00
full: $(ASSETS_BUILDDIR)/webassets
ifneq ("$(OS)", "windows")
$(MAKE) all WEBASSETS_TAG="webassets_embed"
endif
2016-03-18 21:54:20 +00:00
#
# make full-ent - Builds Teleport enterprise binaries
#
.PHONY:full-ent
full-ent:
ifneq ("$(OS)", "windows")
@if [ -f e/Makefile ]; then \
2021-06-28 19:06:47 +00:00
rm $(ASSETS_BUILDDIR)/webassets; \
$(MAKE) -C e full; fi
endif
#
# make clean - Removed all build artifacts.
#
2016-03-19 20:43:23 +00:00
.PHONY: clean
2016-01-17 22:50:00 +00:00
clean:
2018-09-27 01:21:45 +00:00
@echo "---> Cleaning up OSS build artifacts."
2016-03-19 20:43:23 +00:00
rm -rf $(BUILDDIR)
rm -rf $(ER_BPF_BUILDDIR)
rm -rf $(RS_BPF_BUILDDIR)
-go clean -cache
rm -rf $(GOPKGDIR)
2016-06-14 23:52:32 +00:00
rm -rf teleport
2017-01-16 07:25:37 +00:00
rm -rf *.gz
rm -rf *.zip
2017-09-19 19:17:23 +00:00
rm -f gitref.go
2016-01-17 22:50:00 +00:00
#
# make release - Produces a binary release tarball.
2018-02-24 01:23:09 +00:00
#
.PHONY:
export
release:
2018-09-27 01:21:45 +00:00
@echo "---> $(RELEASE_MESSAGE)"
ifeq ("$(OS)", "windows")
$(MAKE) --no-print-directory release-windows
else
$(MAKE) --no-print-directory release-unix
endif
# These are aliases used to make build commands uniform.
.PHONY: release-amd64
release-amd64:
$(MAKE) release ARCH=amd64
.PHONY: release-386
release-386:
$(MAKE) release ARCH=386
.PHONY: release-arm
release-arm:
$(MAKE) release ARCH=arm
.PHONY: release-arm64
release-arm64:
$(MAKE) release ARCH=arm64
#
# make release-unix - Produces a binary release tarball containing teleport,
# tctl, and tsh.
#
.PHONY:
release-unix: clean full
2018-09-27 01:21:45 +00:00
@echo "---> Creating OSS release archive."
mkdir teleport
cp -rf $(BUILDDIR)/* \
examples \
build.assets/install\
README.md \
CHANGELOG.md \
teleport/
echo $(GITTAG) > teleport/VERSION
2021-06-28 19:06:47 +00:00
tar --sort=name --owner=root:0 --group=root:0 --mtime='UTC 2015-03-02' --format=gnu -c teleport | gzip -n > $(RELEASE).tar.gz
rm -rf teleport
2018-09-27 01:21:45 +00:00
@echo "---> Created $(RELEASE).tar.gz."
@if [ -f e/Makefile ]; then \
2021-06-28 19:06:47 +00:00
rm -fr $(ASSETS_BUILDDIR)/webassets; \
$(MAKE) -C e release; \
fi
#
# make release-windows - Produces a binary release tarball containing teleport,
# tctl, and tsh.
#
.PHONY:
release-windows: clean all
2018-09-27 01:21:45 +00:00
@echo "---> Creating OSS release archive."
mkdir teleport
cp -rf $(BUILDDIR)/* \
README.md \
CHANGELOG.md \
teleport/
mv teleport/tsh teleport/tsh.exe
echo $(GITTAG) > teleport/VERSION
zip -9 -y -r -q $(RELEASE).zip teleport/
rm -rf teleport/
2018-09-27 01:21:45 +00:00
@echo "---> Created $(RELEASE).zip."
Teleport 4.3 Docs (#3423) * Base fork for 4.3 docs * [docs] external email identities and Kube Users (#3628) * Base fork for 4.3 docs * [docs] external email identities and Kube Users (#3628) * Remove trailing whitespace from docs files Some editors will do this automatically on save. This causes a lot of diffs when editing the docs in such an editor. Clean them up once now and we'll try to keep it tidy going forward. * Add make rules for docs whitespace and milv docs-test-whitespace: checks for trailing whitespace in all .md files under docs/. docs-fix-whitespace: removes trailing whitespace in all .md files under docs/. docs-test-links: runs milv in all docs/ subdirectories that have milv.config.yaml. docs-test: runs whitespace and links tests, used during `make docs` * Document the new `--use-local-ssh-agent` flag for tsh The flag is used to bypass the local SSH agent even when it's running. Specifically, this helps with agents that don't support certs. The flag was added in #3721 * Remove pam_script.so docs from SSH PAM page With #3725 we now populate teleport-specific env vars in a way that's accessible to `pam_exec.so`. There's no longer any reason to install pam_script.so separately and duplicate our docs. Updates #3692 * Using the correct --insecure-no-tls flag * Run docs-fix-whitespace make rule in a busybox container * Fixes #3414 Co-authored-by: Andrew Lytvynov <andrew@gravitational.com> Co-authored-by: Gus Luxton <gus@gravitational.com> Co-authored-by: Steven Martin <steven@gravitational.com> Co-authored-by: Gus Luxton <webvictim@gmail.com>
2020-06-18 00:09:41 +00:00
#
# Remove trailing whitespace in all markdown files under docs/.
#
# Note: this runs in a busybox container to avoid incompatibilities between
# linux and macos CLI tools.
#
.PHONY:docs-fix-whitespace
docs-fix-whitespace:
docker run --rm -v $(PWD):/teleport busybox \
find /teleport/docs/ -type f -name '*.md' -exec sed -E -i 's/\s+$$//g' '{}' \;
#
# Test docs for trailing whitespace and broken links
#
.PHONY:docs-test
2021-03-10 18:01:48 +00:00
docs-test: docs-test-whitespace
Teleport 4.3 Docs (#3423) * Base fork for 4.3 docs * [docs] external email identities and Kube Users (#3628) * Base fork for 4.3 docs * [docs] external email identities and Kube Users (#3628) * Remove trailing whitespace from docs files Some editors will do this automatically on save. This causes a lot of diffs when editing the docs in such an editor. Clean them up once now and we'll try to keep it tidy going forward. * Add make rules for docs whitespace and milv docs-test-whitespace: checks for trailing whitespace in all .md files under docs/. docs-fix-whitespace: removes trailing whitespace in all .md files under docs/. docs-test-links: runs milv in all docs/ subdirectories that have milv.config.yaml. docs-test: runs whitespace and links tests, used during `make docs` * Document the new `--use-local-ssh-agent` flag for tsh The flag is used to bypass the local SSH agent even when it's running. Specifically, this helps with agents that don't support certs. The flag was added in #3721 * Remove pam_script.so docs from SSH PAM page With #3725 we now populate teleport-specific env vars in a way that's accessible to `pam_exec.so`. There's no longer any reason to install pam_script.so separately and duplicate our docs. Updates #3692 * Using the correct --insecure-no-tls flag * Run docs-fix-whitespace make rule in a busybox container * Fixes #3414 Co-authored-by: Andrew Lytvynov <andrew@gravitational.com> Co-authored-by: Gus Luxton <gus@gravitational.com> Co-authored-by: Steven Martin <steven@gravitational.com> Co-authored-by: Gus Luxton <webvictim@gmail.com>
2020-06-18 00:09:41 +00:00
#
# Check for trailing whitespace in all markdown files under docs/
#
.PHONY:docs-test-whitespace
docs-test-whitespace:
if find docs/ -type f -name '*.md' | xargs grep -E '\s+$$'; then \
echo "trailing whitespace found in docs/ (see above)"; \
echo "run 'make docs-fix-whitespace' to fix it"; \
exit 1; \
fi
2016-02-16 21:18:58 +00:00
#
# Runs all Go/shell tests, called by CI/CD.
#
.PHONY: test
test: test-sh test-api test-go
#
# Runs all Go tests except integration, called by CI/CD.
# Chaos tests have high concurrency, run without race detector and have TestChaos prefix.
2016-02-16 21:18:58 +00:00
#
.PHONY: test-go
2021-04-09 23:20:56 +00:00
test-go: ensure-webassets bpf-bytecode
test-go: FLAGS ?= '-race'
test-go: PACKAGES := $(shell go list ./... | grep -v integration)
test-go: CHAOS_FOLDERS := $(shell find . -type f -name '*chaos*.go' -not -path '*/vendor/*' | xargs dirname | uniq)
test-go: $(VERSRC)
2021-04-09 23:20:56 +00:00
$(CGOFLAG) go test -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG)" $(PACKAGES) $(FLAGS) $(ADDFLAGS)
$(CGOFLAG) go test -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG)" -test.run=TestChaos $(CHAOS_FOLDERS) -cover $(ADDFLAGS)
2021-04-09 23:20:56 +00:00
#
# Runs all Go tests except integration and chaos, called by CI/CD.
#
UNIT_ROOT_REGEX := ^TestRoot
.PHONY: test-go-root
test-go-root: ensure-webassets bpf-bytecode
test-go-root: FLAGS ?= '-race'
test-go-root: PACKAGES := $(shell go list $(ADDFLAGS) ./... | grep -v integration)
2021-04-09 23:20:56 +00:00
test-go-root: $(VERSRC)
$(CGOFLAG) go test -run "$(UNIT_ROOT_REGEX)" -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG)" $(PACKAGES) $(FLAGS) $(ADDFLAGS)
# Runs API Go tests. These have to be run separately as the package name is different.
#
.PHONY: test-api
test-api:
test-api: FLAGS ?= '-race'
test-api: PACKAGES := $(shell cd api && go list ./...)
test-api: $(VERSRC)
2021-04-09 23:20:56 +00:00
$(CGOFLAG) go test -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG)" $(PACKAGES) $(FLAGS) $(ADDFLAGS)
# Find and run all shell script unit tests (using https://github.com/bats-core/bats-core)
.PHONY: test-sh
test-sh:
@if ! type bats 2>&1 >/dev/null; then \
echo "Not running 'test-sh' target as 'bats' is not installed."; \
if [ "$${DRONE}" = "true" ]; then echo "This is a failure when running in CI." && exit 1; fi; \
exit 0; \
fi; \
find . -iname "*.bats" -exec dirname {} \; | uniq | xargs -t -L1 bats $(BATSFLAGS)
#
# Integration tests. Need a TTY to work.
2021-02-15 19:43:39 +00:00
# Any tests which need to run as root must be skipped during regular integration testing.
#
.PHONY: integration
integration: FLAGS ?= -v -race
integration: PACKAGES := $(shell go list ./... | grep integration)
2018-02-24 01:23:09 +00:00
integration:
2018-06-15 22:05:15 +00:00
@echo KUBECONFIG is: $(KUBECONFIG), TEST_KUBE: $(TEST_KUBE)
2021-04-09 23:20:56 +00:00
$(CGOFLAG) go test -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG)" $(PACKAGES) $(FLAGS)
2021-02-15 19:43:39 +00:00
#
# Integration tests which need to be run as root in order to complete successfully
# are run separately to all other integration tests. Need a TTY to work.
#
INTEGRATION_ROOT_REGEX := ^TestRoot
.PHONY: integration-root
integration-root: FLAGS ?= -v -race
integration-root: PACKAGES := $(shell go list ./... | grep integration)
2021-02-15 19:43:39 +00:00
integration-root:
2021-04-09 23:20:56 +00:00
$(CGOFLAG) go test -run "$(INTEGRATION_ROOT_REGEX)" $(PACKAGES) $(FLAGS)
2021-02-15 19:43:39 +00:00
#
# Lint the Go code.
# By default lint scans the entire repo. Pass GO_LINT_FLAGS='--new' to only scan local
# changes (or last commit).
#
.PHONY: lint
lint: lint-sh lint-helm lint-api lint-go
.PHONY: lint-go
lint-go: GO_LINT_FLAGS ?=
lint-go:
golangci-lint run -c .golangci.yml $(GO_LINT_FLAGS)
# api is no longer part of the teleport package, so golangci-lint skips it by default
# GOMODCACHE needs to be set here as api downloads dependencies and cannot write to /go/pkg/mod/cache
.PHONY: lint-api
lint-api: GO_LINT_API_FLAGS ?=
lint-api:
cd api && golangci-lint run -c ../.golangci.yml $(GO_LINT_API_FLAGS)
# TODO(awly): remove the `--exclude` flag after cleaning up existing scripts
.PHONY: lint-sh
lint-sh: SH_LINT_FLAGS ?=
lint-sh:
find . -type f -name '*.sh' | grep -v vendor | xargs \
shellcheck \
--exclude=SC2086 \
$(SH_LINT_FLAGS)
2020-11-17 14:49:56 +00:00
# lint AWS AMI scripts
# SC1091 prints errors when "source" directives are not followed
find assets/aws/files/bin -type f | xargs \
shellcheck \
--exclude=SC2086 \
--exclude=SC1091 \
--exclude=SC2129 \
2020-11-17 14:49:56 +00:00
$(SH_LINT_FLAGS)
# Lints all the Helm charts found in directories under examples/chart and exits on failure
# If there is a .lint directory inside, the chart gets linted once for each .yaml file in that directory
# We inherit yamllint's 'relaxed' configuration as it's more compatible with Helm output and will only error on
# show-stopping issues. Kubernetes' YAML parser is not particularly fussy.
# If errors are found, the file is printed with line numbers to aid in debugging.
.PHONY: lint-helm
lint-helm:
@if ! type yamllint 2>&1 >/dev/null; then \
echo "Not running 'lint-helm' target as 'yamllint' is not installed."; \
if [ "$${DRONE}" = "true" ]; then echo "This is a failure when running in CI." && exit 1; fi; \
exit 0; \
fi; \
for CHART in $$(find examples/chart -mindepth 1 -maxdepth 1 -type d); do \
if [ -d $${CHART}/.lint ]; then \
for VALUES in $${CHART}/.lint/*.yaml; do \
export HELM_TEMP=$$(mktemp); \
echo -n "Using values from '$${VALUES}': "; \
yamllint -c examples/chart/.lint-config.yaml $${VALUES} || { cat -en $${VALUES}; exit 1; }; \
helm lint --strict $${CHART} -f $${VALUES} || exit 1; \
helm template test $${CHART} -f $${VALUES} 1>$${HELM_TEMP} || exit 1; \
yamllint -c examples/chart/.lint-config.yaml $${HELM_TEMP} || { cat -en $${HELM_TEMP}; exit 1; }; \
done \
else \
export HELM_TEMP=$$(mktemp); \
helm lint --strict $${CHART} || exit 1; \
helm template test $${CHART} 1>$${HELM_TEMP} || exit 1; \
yamllint -c examples/chart/.lint-config.yaml $${HELM_TEMP} || { cat -en $${HELM_TEMP}; exit 1; }; \
fi; \
done
2021-06-18 18:52:55 +00:00
# This rule triggers re-generation of version files if Makefile changes.
.PHONY: version
version: $(VERSRC)
# This rule triggers re-generation of version files specified if Makefile changes.
$(VERSRC): Makefile
2016-12-31 08:13:41 +00:00
VERSION=$(VERSION) $(MAKE) -f version.mk setver
2016-06-13 18:27:19 +00:00
# make tag - prints a tag to use with git for the current version
# To put a new release on Github:
# - bump VERSION variable
# - run make setver
# - commit changes to git
# - build binaries with 'make release'
# - run `make tag` and use its output to 'git tag' and 'git push --tags'
.PHONY: update-tag
update-tag:
@test $(VERSION)
git tag $(GITTAG)
git tag api/$(GITTAG)
git push origin $(GITTAG) && git push origin api/$(GITTAG)
2021-06-28 19:06:47 +00:00
# build/webassets directory contains the web assets (UI) which get
# embedded in the teleport binary
$(ASSETS_BUILDDIR)/webassets: ensure-webassets $(ASSETS_BUILDDIR)
ifneq ("$(OS)", "windows")
2021-06-28 19:06:47 +00:00
@echo "---> Copying OSS web assets."; \
rm -rf $(ASSETS_BUILDDIR)/webassets; \
mkdir $(ASSETS_BUILDDIR)/webassets; \
cd webassets/teleport/ ; cp -r . ../../$@
endif
2015-03-02 20:11:23 +00:00
$(ASSETS_BUILDDIR):
mkdir -p $@
.PHONY: test-package
test-package: remove-temp-files
go test -v ./$(p)
2015-03-02 20:11:23 +00:00
.PHONY: test-grep-package
test-grep-package: remove-temp-files
go test -v ./$(p) -check.f=$(e)
2015-03-02 20:11:23 +00:00
.PHONY: cover-package
2015-05-04 15:28:32 +00:00
cover-package: remove-temp-files
go test -v ./$(p) -coverprofile=/tmp/coverage.out
go tool cover -html=/tmp/coverage.out
2015-03-02 20:11:23 +00:00
.PHONY: profile
2015-03-02 20:11:23 +00:00
profile:
go tool pprof http://localhost:6060/debug/pprof/profile
2015-03-02 20:11:23 +00:00
.PHONY: sloccount
2015-03-02 20:11:23 +00:00
sloccount:
find . -path ./vendor -prune -o -name "*.go" -print0 | xargs -0 wc -l
.PHONY: remove-temp-files
remove-temp-files:
find . -name flymake_* -delete
# Dockerized build: useful for making Linux releases on OSX
.PHONY:docker
docker:
make -C build.assets build
# Dockerized build: useful for making Linux binaries on OSX
.PHONY:docker-binaries
2020-07-20 20:18:00 +00:00
docker-binaries: clean
make -C build.assets build-binaries
# Interactively enters a Docker container (which you can build and run Teleport inside of)
.PHONY:enter
enter:
make -C build.assets enter
2017-05-27 01:03:19 +00:00
# grpc generates GRPC stubs from service definitions
2017-05-27 01:03:19 +00:00
.PHONY: grpc
grpc:
make -C build.assets grpc
2017-05-27 01:03:19 +00:00
# buildbox-grpc generates GRPC stubs inside buildbox
2017-05-27 01:03:19 +00:00
.PHONY: buildbox-grpc
buildbox-grpc:
# standard GRPC output
echo $$PROTO_INCLUDE
2021-04-09 23:20:56 +00:00
find lib/ -iname *.proto | xargs $(CLANG_FORMAT) -i -style='{ColumnLimit: 100, IndentWidth: 4, Language: Proto}'
find api/ -iname *.proto | xargs $(CLANG_FORMAT) -i -style='{ColumnLimit: 100, IndentWidth: 4, Language: Proto}'
Merge Teleport V4.3 UI branch to master (#3583) * Add monorepo * Add reset/passwd capability for local users (#3287) * Add UserTokens to allow password resets * Pass context down through ChangePasswordWithToken * Rename UserToken to ResetPasswordToken * Add auto formatting for proto files * Add common Marshaller interfaces to reset password token * Allow enterprise "tctl" reuse OSS user methods (#3344) * Pass localAuthEnabled flag to UI (#3412) * Added LocalAuthEnabled prop to WebConfigAuthSetting struct in webconfig.go * Added LocalAuthEnabled state as part of webCfg in apiserver.go * update e-refs * Fix a regression bug after merge * Update tctl CLI output msgs (#3442) * Use local user client when resolving user roles * Update webapps ref * Add and retrieve fields from Cluster struct (#3476) * Set Teleport versions for node, auth, proxy init heartbeat * Add and retrieve fields NodeCount, PublicURL, AuthVersion from Clusters * Remove debug logging to avoid log pollution when getting public_addr of proxy * Create helper func GuessProxyHost to get the public_addr of a proxy host * Refactor newResetPasswordToken to use GuessProxyHost and remove publicUrl func * Remove webapps submodule * Add webassets submodule * Replace webapps sub-module reference with webassets * Update webassets path in Makefile * Update webassets 1b11b26 Simplify and clean up Makefile (#62) https://github.com/gravitational/webapps/commit/1b11b26 * Retrieve cluster details for user context (#3515) * Let GuessProxyHost also return proxy's version * Unit test GuessProxyHostAndVersion & GetClusterDetails * Update webassets 4dfef4e Fix build pipeline (#66) https://github.com/gravitational/webapps/commit/4dfef4e * Update e-ref * Update webassets 0647568 Fix OSS redirects https://github.com/gravitational/webapps/commit/0647568 * update e-ref * Update webassets e0f4189 Address security audit warnings Updates "minimist" package which is used by 7y old "optimist". https://github.com/gravitational/webapps/commit/e0f4189 * Add new attr to Session struct (#3574) * Add fields ServerHostname and ServerAddr * Set these fields on newSession * Ensure webassets submodule during build * Update e-ref * Ensure webassets before running unit-tests * Update E-ref Co-authored-by: Lisa Kim <lisa@gravitational.com> Co-authored-by: Pierre Beaucamp <pierre@gravitational.com> Co-authored-by: Jenkins <jenkins@gravitational.io>
2020-04-15 19:35:26 +00:00
protoc -I=.:$$PROTO_INCLUDE \
--proto_path=api/types/events \
--gogofast_out=plugins=grpc:api/types/events \
events.proto
Events and GRPC API This commit introduces several key changes to Teleport backend and API infrastructure in order to achieve scalability improvements on 10K+ node deployments. Events and plain keyspace -------------------------- New backend interface supports events, pagination and range queries and moves away from buckets to plain keyspace, what better aligns with DynamoDB and Etcd featuring similar interfaces. All backend implementations are exposing Events API, allowing multiple subscribers to consume the same event stream and avoid polling database. Replacing BoltDB, Dir with SQLite ------------------------------- BoltDB backend does not support having two processes access the database at the same time. This prevented Teleport using BoltDB backend to be live reloaded. SQLite supports reads/writes by multiple processes and makes Dir backend obsolete as SQLite is more efficient on larger collections, supports transactions and can detect data corruption. Teleport automatically migrates data from Bolt and Dir backends into SQLite. GRPC API and protobuf resources ------------------------------- GRPC API has been introduced for the auth server. The auth server now serves both GRPC and JSON-HTTP API on the same TLS socket and uses the same client certificate authentication. All future API methods should use GRPC and HTTP-JSON API is considered obsolete. In addition to that some resources like Server and CertificateAuthority are now generated from protobuf service specifications in a way that is fully backward compatible with original JSON spec and schema, so the same resource can be encoded and decoded from JSON, YAML and protobuf. All models should be refactored into new proto specification over time. Streaming presence service -------------------------- In order to cut bandwidth, nodes are sending full updates only when changes to labels or spec have occured, otherwise new light-weight GRPC keep alive updates are sent over to the presence service, reducing bandwidth usage on multi-node deployments. In addition to that nodes are no longer polling auth server for certificate authority rotation updates, instead they subscribe to event updates to detect updates as soon as they happen. This is a new API, so the errors are inevitable, that's why polling is still done, but on a way slower rate.
2018-11-07 23:33:38 +00:00
protoc -I=.:$$PROTO_INCLUDE \
--proto_path=api/types/webauthn \
--gogofast_out=plugins=grpc:api/types/webauthn \
webauthn.proto
protoc -I=.:$$PROTO_INCLUDE \
--proto_path=api/types/wrappers \
--gogofast_out=plugins=grpc:api/types/wrappers \
wrappers.proto
protoc -I=.:$$PROTO_INCLUDE \
--proto_path=api/types \
--gogofast_out=plugins=grpc:api/types \
types.proto
Events and GRPC API This commit introduces several key changes to Teleport backend and API infrastructure in order to achieve scalability improvements on 10K+ node deployments. Events and plain keyspace -------------------------- New backend interface supports events, pagination and range queries and moves away from buckets to plain keyspace, what better aligns with DynamoDB and Etcd featuring similar interfaces. All backend implementations are exposing Events API, allowing multiple subscribers to consume the same event stream and avoid polling database. Replacing BoltDB, Dir with SQLite ------------------------------- BoltDB backend does not support having two processes access the database at the same time. This prevented Teleport using BoltDB backend to be live reloaded. SQLite supports reads/writes by multiple processes and makes Dir backend obsolete as SQLite is more efficient on larger collections, supports transactions and can detect data corruption. Teleport automatically migrates data from Bolt and Dir backends into SQLite. GRPC API and protobuf resources ------------------------------- GRPC API has been introduced for the auth server. The auth server now serves both GRPC and JSON-HTTP API on the same TLS socket and uses the same client certificate authentication. All future API methods should use GRPC and HTTP-JSON API is considered obsolete. In addition to that some resources like Server and CertificateAuthority are now generated from protobuf service specifications in a way that is fully backward compatible with original JSON spec and schema, so the same resource can be encoded and decoded from JSON, YAML and protobuf. All models should be refactored into new proto specification over time. Streaming presence service -------------------------- In order to cut bandwidth, nodes are sending full updates only when changes to labels or spec have occured, otherwise new light-weight GRPC keep alive updates are sent over to the presence service, reducing bandwidth usage on multi-node deployments. In addition to that nodes are no longer polling auth server for certificate authority rotation updates, instead they subscribe to event updates to detect updates as soon as they happen. This is a new API, so the errors are inevitable, that's why polling is still done, but on a way slower rate.
2018-11-07 23:33:38 +00:00
protoc -I=.:$$PROTO_INCLUDE \
2020-12-29 19:00:54 +00:00
--proto_path=api/client/proto \
--gogofast_out=plugins=grpc:api/client/proto \
authservice.proto
2017-05-27 01:03:19 +00:00
cd lib/multiplexer/test && protoc -I=.:$$PROTO_INCLUDE \
--gogofast_out=plugins=grpc:.\
*.proto
cd lib/web && protoc -I=.:$$PROTO_INCLUDE \
--gogofast_out=plugins=grpc:.\
*.proto
.PHONY: goinstall
goinstall:
go install $(BUILDFLAGS) \
github.com/gravitational/teleport/tool/tsh \
github.com/gravitational/teleport/tool/teleport \
github.com/gravitational/teleport/tool/tctl
2018-02-24 01:23:09 +00:00
# make install will installs system-wide teleport
.PHONY: install
install: build
@echo "\n** Make sure to run 'make install' as root! **\n"
cp -f $(BUILDDIR)/tctl $(BINDIR)/
cp -f $(BUILDDIR)/tsh $(BINDIR)/
cp -f $(BUILDDIR)/teleport $(BINDIR)/
mkdir -p $(DATADIR)
# Docker image build. Always build the binaries themselves within docker (see
# the "docker" rule) to avoid dependencies on the host libc version.
.PHONY: image
2020-07-20 20:18:00 +00:00
image: clean docker-binaries
2018-06-20 23:36:54 +00:00
cp ./build.assets/charts/Dockerfile $(BUILDDIR)/
cd $(BUILDDIR) && docker build --no-cache . -t $(DOCKER_IMAGE):$(VERSION)
if [ -f e/Makefile ]; then $(MAKE) -C e image; fi
.PHONY: publish
publish: image
docker push $(DOCKER_IMAGE):$(VERSION)
if [ -f e/Makefile ]; then $(MAKE) -C e publish; fi
# Docker image build in CI.
# This is run to build and push Docker images to a private repository as part of the build process.
# When we are ready to make the images public after testing (i.e. when publishing a release), we pull these
# images down, retag them and push them up to the production repo so they're available for use.
# This job can be removed/consolidated after we switch over completely from using Jenkins to using Drone.
.PHONY: image-ci
image-ci: clean docker-binaries
cp ./build.assets/charts/Dockerfile $(BUILDDIR)/
cd $(BUILDDIR) && docker build --no-cache . -t $(DOCKER_IMAGE_CI):$(VERSION)
if [ -f e/Makefile ]; then $(MAKE) -C e image-ci; fi
.PHONY: publish-ci
publish-ci: image-ci
docker push $(DOCKER_IMAGE_CI):$(VERSION)
if [ -f e/Makefile ]; then $(MAKE) -C e publish-ci; fi
.PHONY: print-version
print-version:
@echo $(VERSION)
.PHONY: chart-ent
chart-ent:
$(MAKE) -C e chart
RUNTIME_SECTION ?=
TARBALL_PATH_SECTION ?=
ifneq ("$(RUNTIME)", "")
RUNTIME_SECTION := -r $(RUNTIME)
endif
ifneq ("$(OSS_TARBALL_PATH)", "")
TARBALL_PATH_SECTION := -s $(OSS_TARBALL_PATH)
endif
# build .pkg
.PHONY: pkg
pkg:
mkdir -p $(BUILDDIR)/
cp ./build.assets/build-package.sh $(BUILDDIR)/
chmod +x $(BUILDDIR)/build-package.sh
# arch and runtime are currently ignored on OS X
# we pass them through for consistency - they will be dropped by the build script
cd $(BUILDDIR) && ./build-package.sh -t oss -v $(VERSION) -p pkg -a $(ARCH) $(RUNTIME_SECTION) $(TARBALL_PATH_SECTION)
if [ -f e/Makefile ]; then $(MAKE) -C e pkg; fi
# build tsh client-only .pkg
.PHONY: pkg-tsh
pkg-tsh:
mkdir -p $(BUILDDIR)/
cp ./build.assets/build-package.sh $(BUILDDIR)/
chmod +x $(BUILDDIR)/build-package.sh
# arch and runtime are currently ignored on OS X
# we pass them through for consistency - they will be dropped by the build script
cd $(BUILDDIR) && ./build-package.sh -t oss -v $(VERSION) -p pkg -a $(ARCH) -m tsh $(RUNTIME_SECTION) $(TARBALL_PATH_SECTION)
# build .rpm
.PHONY: rpm
rpm:
mkdir -p $(BUILDDIR)/
cp ./build.assets/build-package.sh $(BUILDDIR)/
chmod +x $(BUILDDIR)/build-package.sh
cp -a ./build.assets/rpm $(BUILDDIR)/
cp -a ./build.assets/rpm-sign $(BUILDDIR)/
cd $(BUILDDIR) && ./build-package.sh -t oss -v $(VERSION) -p rpm -a $(ARCH) $(RUNTIME_SECTION) $(TARBALL_PATH_SECTION)
if [ -f e/Makefile ]; then $(MAKE) -C e rpm; fi
# build unsigned .rpm (for testing)
.PHONY: rpm-unsigned
rpm-unsigned:
$(MAKE) UNSIGNED_RPM=true rpm
# build .deb
.PHONY: deb
deb:
mkdir -p $(BUILDDIR)/
cp ./build.assets/build-package.sh $(BUILDDIR)/
chmod +x $(BUILDDIR)/build-package.sh
cd $(BUILDDIR) && ./build-package.sh -t oss -v $(VERSION) -p deb -a $(ARCH) $(RUNTIME_SECTION) $(TARBALL_PATH_SECTION)
if [ -f e/Makefile ]; then $(MAKE) -C e deb; fi
# update Helm chart versions
# this isn't a 'proper' semver regex but should cover most cases
2020-03-27 17:15:33 +00:00
# the order of parameters in sed's extended regex mode matters; the
# dash (-) must be the last character for this to work as expected
.PHONY: update-helm-charts
update-helm-charts:
sed -i -E "s/^ tag: [a-z0-9.-]+$$/ tag: $(VERSION)/" examples/chart/teleport/values.yaml
sed -i -E "s/^ tag: [a-z0-9.-]+$$/ tag: $(VERSION)/" examples/chart/teleport-auto-trustedcluster/values.yaml
sed -i -E "s/^ tag: [a-z0-9.-]+$$/ tag: $(VERSION)/" examples/chart/teleport-daemonset/values.yaml
Merge Teleport V4.3 UI branch to master (#3583) * Add monorepo * Add reset/passwd capability for local users (#3287) * Add UserTokens to allow password resets * Pass context down through ChangePasswordWithToken * Rename UserToken to ResetPasswordToken * Add auto formatting for proto files * Add common Marshaller interfaces to reset password token * Allow enterprise "tctl" reuse OSS user methods (#3344) * Pass localAuthEnabled flag to UI (#3412) * Added LocalAuthEnabled prop to WebConfigAuthSetting struct in webconfig.go * Added LocalAuthEnabled state as part of webCfg in apiserver.go * update e-refs * Fix a regression bug after merge * Update tctl CLI output msgs (#3442) * Use local user client when resolving user roles * Update webapps ref * Add and retrieve fields from Cluster struct (#3476) * Set Teleport versions for node, auth, proxy init heartbeat * Add and retrieve fields NodeCount, PublicURL, AuthVersion from Clusters * Remove debug logging to avoid log pollution when getting public_addr of proxy * Create helper func GuessProxyHost to get the public_addr of a proxy host * Refactor newResetPasswordToken to use GuessProxyHost and remove publicUrl func * Remove webapps submodule * Add webassets submodule * Replace webapps sub-module reference with webassets * Update webassets path in Makefile * Update webassets 1b11b26 Simplify and clean up Makefile (#62) https://github.com/gravitational/webapps/commit/1b11b26 * Retrieve cluster details for user context (#3515) * Let GuessProxyHost also return proxy's version * Unit test GuessProxyHostAndVersion & GetClusterDetails * Update webassets 4dfef4e Fix build pipeline (#66) https://github.com/gravitational/webapps/commit/4dfef4e * Update e-ref * Update webassets 0647568 Fix OSS redirects https://github.com/gravitational/webapps/commit/0647568 * update e-ref * Update webassets e0f4189 Address security audit warnings Updates "minimist" package which is used by 7y old "optimist". https://github.com/gravitational/webapps/commit/e0f4189 * Add new attr to Session struct (#3574) * Add fields ServerHostname and ServerAddr * Set these fields on newSession * Ensure webassets submodule during build * Update e-ref * Ensure webassets before running unit-tests * Update E-ref Co-authored-by: Lisa Kim <lisa@gravitational.com> Co-authored-by: Pierre Beaucamp <pierre@gravitational.com> Co-authored-by: Jenkins <jenkins@gravitational.io>
2020-04-15 19:35:26 +00:00
.PHONY: ensure-webassets
ensure-webassets:
@if [ ! -d $(shell pwd)/webassets/teleport/ ]; then \
$(MAKE) init-webapps-submodules; \
fi;
.PHONY: ensure-webassets-e
ensure-webassets-e:
@if [ ! -d $(shell pwd)/webassets/e/teleport ]; then \
$(MAKE) init-webapps-submodules-e; \
fi;
.PHONY: init-webapps-submodules
init-webapps-submodules:
echo "init webassets submodule"
git submodule update --init webassets
.PHONY: init-webapps-submodules-e
init-webapps-submodules-e:
echo "init webassets oss and enterprise submodules"
git submodule update --init --recursive webassets
.PHONY: init-submodules-e
init-submodules-e: init-webapps-submodules-e
git submodule init e
git submodule update
.PHONY: update-vendor
update-vendor:
# update modules in api/
cd api && go mod tidy
# update modules in root directory
go mod tidy
go mod vendor
2021-02-23 00:20:43 +00:00
# delete the vendored api package. In its place
# create a symlink to the the original api package
rm -r vendor/github.com/gravitational/teleport/api
cd vendor/github.com/gravitational/teleport && ln -s ../../../../api api
# update-webassets updates the minified code in the webassets repo using the latest webapps
# repo and creates a PR in the teleport repo to update webassets submodule.
.PHONY: update-webassets
update-webassets: WEBAPPS_BRANCH ?= 'master'
update-webassets: TELEPORT_BRANCH ?= 'master'
update-webassets:
build.assets/webapps/update-teleport-webassets.sh -w $(WEBAPPS_BRANCH) -t $(TELEPORT_BRANCH)
# dronegen generates .drone.yml config
.PHONY: dronegen
dronegen:
go run ./dronegen