...

Text file src/github.com/emissary-ingress/emissary/v3/Makefile

Documentation: github.com/emissary-ingress/emissary/v3

     1# Real early setup
     2OSS_HOME := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))# Do this *before* 'include'ing anything else
     3include build-aux/init-sanitize-env.mk
     4include build-aux/init-configure-make-itself.mk
     5include build-aux/prelude.mk # In Haskell, "Prelude" is what they call the stdlib builtins that get get imported by default before anything else
     6include build-aux/tools.mk
     7
     8# To support contributors building project on M1 Macs we will default container builds to run as linux/amd64 rather than
     9# the host architecture. Setting the corresponding environment variable allows overriding it if want to work with other architectures.
    10BUILD_ARCH ?= linux/amd64
    11
    12# Bootstrapping the build env
    13#
    14# _go-version/deps and _go-version/cmd should mostly only be used via
    15# go-version.txt (in deps.mk), but we have declared them early here
    16# for bootstrapping the build env.  Don't use them directly (not via
    17# go-version.txt) except for bootstrapping.
    18_go-version/deps = docker/base-python/Dockerfile
    19_go-version/cmd = sed -En 's,.*https://dl\.google\.com/go/go([0-9a-z.-]*)\.linux-amd64\.tar\.gz.*,\1,p' < $(_go-version/deps)
    20ifneq ($(MAKECMDGOALS),$(OSS_HOME)/build-aux/go-version.txt)
    21  $(call _prelude.go.ensure,$(shell $(_go-version/cmd)))
    22  ifneq ($(filter $(shell go env GOROOT),$(subst :, ,$(shell go env GOPATH))),)
    23    $(error Your $$GOPATH (where *your* Go stuff goes) and $$GOROOT (where Go *itself* is installed) are both set to the same directory ($(shell go env GOROOT)); it is remarkable that it has not blown up catastrophically before now)
    24  endif
    25  ifneq ($(foreach gopath,$(subst :, ,$(shell go env GOPATH)),$(filter $(gopath)/%,$(CURDIR))),)
    26    $(error Your emissary.git checkout is inside of your $$GOPATH ($(shell go env GOPATH)); Emissary-ingress uses Go modules and so GOPATH need not be pointed at it (in a post-modules world, the only role of GOPATH is to store the module download cache); and indeed some of the Kubernetes tools will get confused if GOPATH is pointed at it)
    27  endif
    28
    29  VERSION := $(or $(VERSION),$(shell go run ./tools/src/goversion))
    30  $(if $(filter v3.%,$(VERSION)),\
    31    ,$(error VERSION variable is invalid: It must be a v3.* string, but is '$(VERSION)'))
    32  $(if $(findstring +,$(VERSION)),\
    33    $(error VERSION variable is invalid: It must not contain + characters, but is '$(VERSION)'),)
    34  export VERSION
    35
    36  CHART_VERSION := $(or $(CHART_VERSION),$(shell go run ./tools/src/goversion --dir-prefix=chart))
    37  $(if $(filter v8.%,$(CHART_VERSION)),\
    38    ,$(error CHART_VERSION variable is invalid: It must be a v8.* string, but is '$(CHART_VERSION)'))
    39  export CHART_VERSION
    40
    41  $(info [make] VERSION=$(VERSION))
    42  $(info [make] CHART_VERSION=$(CHART_VERSION))
    43endif
    44
    45# If SOURCE_DATE_EPOCH isn't set, AND the tree isn't dirty, then set
    46# SOURCE_DATE_EPOCH to the commit timestamp.
    47#
    48# if [[ -z "$SOURCE_DATE_EPOCH" ]] && [[ -z "$(git status --porcelain)" ]]; then
    49ifeq ($(SOURCE_DATE_EPOCH)$(shell git status --porcelain),)
    50  SOURCE_DATE_EPOCH := $(shell git log -1 --pretty=%ct)
    51endif
    52ifneq ($(SOURCE_DATE_EPOCH),)
    53  export SOURCE_DATE_EPOCH
    54  $(info [make] SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH))
    55endif
    56
    57# Everything else...
    58
    59NAME ?= emissary
    60_git_remote_urls := $(shell git remote | xargs -n1 git remote get-url --all)
    61IS_PRIVATE ?= $(findstring private,$(_git_remote_urls))
    62
    63include $(OSS_HOME)/build-aux/ci.mk
    64include $(OSS_HOME)/build-aux/deps.mk
    65include $(OSS_HOME)/build-aux/main.mk
    66include $(OSS_HOME)/build-aux/check.mk
    67include $(OSS_HOME)/build-aux/builder.mk
    68include $(OSS_HOME)/_cxx/envoy.mk
    69include $(OSS_HOME)/releng/release.mk
    70
    71$(call module,ambassador,$(OSS_HOME))
    72
    73include $(OSS_HOME)/build-aux/generate.mk
    74include $(OSS_HOME)/build-aux/lint.mk
    75
    76.git/hooks/prepare-commit-msg:
    77	ln -s $(OSS_HOME)/tools/hooks/prepare-commit-msg $(OSS_HOME)/.git/hooks/prepare-commit-msg
    78
    79githooks: .git/hooks/prepare-commit-msg
    80
    81preflight-dev-kubeconfig:
    82	@if [ -z "$(DEV_KUBECONFIG)" ] ; then \
    83		echo "DEV_KUBECONFIG must be set"; \
    84		exit 1; \
    85	fi
    86.PHONY: preflight-dev-kubeconfig
    87
    88deploy: push preflight-cluster
    89	$(MAKE) deploy-only
    90.PHONY: deploy
    91
    92deploy-only: preflight-dev-kubeconfig $(tools/kubectl) build-output/yaml-$(patsubst v%,%,$(VERSION)) $(boguschart_dir)
    93	mkdir -p $(OSS_HOME)/build/helm/ && \
    94	($(tools/kubectl) --kubeconfig $(DEV_KUBECONFIG) create ns ambassador || true) && \
    95	helm template ambassador --output-dir $(OSS_HOME)/build/helm -n ambassador $(boguschart_dir) \
    96		--set createNamespace=true \
    97		--set service.selector.service=ambassador \
    98		--set replicaCount=1 \
    99		--set enableAES=false \
   100		--set image.fullImageOverride=$$(sed -n 2p docker/$(LCNAME).docker.push.remote) && \
   101	$(tools/kubectl) --kubeconfig $(DEV_KUBECONFIG) apply -f build-output/yaml-$(patsubst v%,%,$(VERSION))/emissary-crds.yaml
   102	$(tools/kubectl) --kubeconfig $(DEV_KUBECONFIG) -n emissary-system wait --for condition=available --timeout=90s deploy emissary-apiext && \
   103	$(tools/kubectl) --kubeconfig $(DEV_KUBECONFIG) apply -f $(OSS_HOME)/build/helm/emissary-ingress/templates && \
   104	rm -rf $(OSS_HOME)/build/helm
   105	$(tools/kubectl) --kubeconfig $(DEV_KUBECONFIG) -n ambassador wait --for condition=available --timeout=90s deploy --all
   106	@printf "$(GRN)Your ambassador service IP:$(END) $(BLD)$$($(tools/kubectl) --kubeconfig $(DEV_KUBECONFIG) get -n ambassador service ambassador -o 'go-template={{range .status.loadBalancer.ingress}}{{print .ip "\n"}}{{end}}')$(END)\n"
   107	@printf "$(GRN)Your ambassador image:$(END) $(BLD)$$($(tools/kubectl) --kubeconfig $(DEV_KUBECONFIG) get -n ambassador deploy ambassador -o 'go-template={{(index .spec.template.spec.containers 0).image}}')$(END)\n"
   108	@printf "$(GRN)Your built image:$(END) $(BLD)$$(sed -n 2p docker/$(LCNAME).docker.push.remote)$(END)\n"
   109.PHONY: deploy-only
   110
   111##############################################
   112##@ Telepresence based runners
   113##############################################
   114
   115.PHONY: tel-quit
   116tel-quit: ## Quit telepresence
   117	telepresence quit
   118
   119tel-list: ## List intercepts
   120	telepresence list
   121
   122EMISSARY_AGENT_ENV=emissary-agent.env
   123
   124.PHONY: intercept-emissary-agent
   125intercept-emissary-agent:
   126	telepresence intercept --namespace ambassador ambassador-agent -p 8080:http \
   127		--http-header=test-$(USER)=1 --preview-url=false --env-file $(EMISSARY_AGENT_ENV)
   128
   129.PHONY: leave-emissary-agent
   130leave-emissary-agent:
   131	telepresence leave ambassador-agent-ambassador
   132
   133RUN_EMISSARY_AGENT=bin/run-emissary-agent.sh
   134$(RUN_EMISSARY_AGENT):
   135	@test -e $(EMISSARY_AGENT_ENV) || echo "Environment file $(EMISSARY_AGENT_ENV) does not exist, please run 'make intercept-emissary-agent' to create it."
   136	echo 'AES_LOG_LEVEL=debug AES_SNAPSHOT_URL=http://ambassador-admin.ambassador:8005/snapshot-external AES_DIAGNOSTICS_URL="http://ambassador-admin.ambassador:8877/ambassador/v0/diag/?json=true" AES_REPORT_DIAGNOSTICS_TO_CLOUD=true go run ./cmd/busyambassador agent' >> $(RUN_EMISSARY_AGENT)
   137	chmod a+x $(RUN_EMISSARY_AGENT)
   138
   139.PHONY: irun-emissary-agent
   140irun-emissary-agent: bin/run-emissary-agent.sh ## Run emissary-agent using the environment variables fetched by the intercept.
   141	bin/run-emissary-agent.sh
   142
   143## Helper target for setting up local dev environment when working with python components
   144## such as pytests, diagd, etc...
   145.PHONY: python-dev-setup
   146python-dev-setup:
   147# recreate venv and upgrade pip
   148	rm -rf venv
   149	python3 -m venv venv
   150	venv/bin/python3 -m pip install --upgrade pip
   151
   152# install deps, dev deps and diagd
   153	./venv/bin/pip install -r python/requirements.txt
   154	./venv/bin/pip install -r python/requirements-dev.txt
   155	./venv/bin/pip install -e python
   156
   157# activate venv
   158	@echo "run 'source ./venv/bin/activate' to activate venv in local shell"
   159
   160# re-generate docs
   161.PHONY: clean-changelog
   162clean-changelog:
   163	rm -f CHANGELOG.md
   164
   165.PHONY: generate-changelog
   166generate-changelog: clean-changelog $(PWD)/CHANGELOG.md

View as plain text