-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
82 lines (65 loc) · 2.57 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
CURRENT_DIR=$(shell pwd)
DIST_DIR=${CURRENT_DIR}/dist
E2E_CLUSTER_NAME=gatewayapi-plugin-e2e
IS_E2E_CLUSTER=$(shell kind get clusters | grep -e "^${E2E_CLUSTER_NAME}$$")
CLUSTER_DELETE ?= true
RUN ?= ''
define add_helm_repo
helm repo add traefik https://traefik.github.io/charts
helm repo add argo https://argoproj.github.io/argo-helm
endef
define setup_cluster
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.1.0/experimental-install.yaml
helm install argo-rollouts argo/argo-rollouts --values ./test/cluster-setup/argo-rollouts-values.yml --version 2.37.2
helm install traefik traefik/traefik --values ./test/cluster-setup/traefik-values.yml --version 31.0.0
endef
define install_k8s_resources
kubectl apply -f ./examples/traefik/stable.yml
kubectl apply -f ./examples/traefik/canary.yml
endef
.PHONY: install-dependencies
install-dependencies:
go mod download
.PHONY: release
release:
make BIN_NAME=gatewayapi-plugin-darwin-amd64 GOOS=darwin GOARCH=amd64 gatewayapi-plugin-build
make BIN_NAME=gatewayapi-plugin-darwin-arm64 GOOS=darwin GOARCH=arm64 gatewayapi-plugin-build
make BIN_NAME=gatewayapi-plugin-linux-amd64 GOOS=linux GOARCH=amd64 gatewayapi-plugin-build
make BIN_NAME=gatewayapi-plugin-linux-arm64 GOOS=linux GOARCH=arm64 gatewayapi-plugin-build
make BIN_NAME=gatewayapi-plugin-windows-amd64.exe GOOS=windows gatewayapi-plugin-build
.PHONY: gatewayapi-plugin-build
gatewayapi-plugin-build:
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -v -o ${DIST_DIR}/${BIN_NAME} .
.PHONY: local-build
local-build:
go build -gcflags=all="-N -l" -o gatewayapi-plugin
.PHONY: lint
lint:
golangci-lint run --fix
.PHONY: unit-tests
unit-tests:
go test -v -count=1 ./pkg/...
.PHONY: setup-e2e-cluster
setup-e2e-cluster:
make BIN_NAME=gatewayapi-plugin-linux-amd64 GOOS=linux GOARCH=amd64 gatewayapi-plugin-build
ifeq (${IS_E2E_CLUSTER},)
kind create cluster --name ${E2E_CLUSTER_NAME} --config ./test/cluster-setup/cluster-config.yml
$(call add_helm_repo)
$(call setup_cluster)
$(call install_k8s_resources)
endif
.PHONY: e2e-tests
e2e-tests: setup-e2e-cluster run-e2e-tests
ifeq (${CLUSTER_DELETE},true)
make clear-e2e-cluster
endif
.PHONY: run-e2e-tests
run-e2e-tests:
go test -v -timeout 1m -count=1 -run ${RUN} ./test/e2e/...
.PHONY: clear-e2e-cluster
clear-e2e-cluster:
kind delete cluster --name ${E2E_CLUSTER_NAME}
# convenience target to run `mkdocs serve` using a docker container
.PHONY: serve-docs
serve-docs: ## serve docs locally
docker run --rm -it -p 8000:8000 -v ${CURRENT_DIR}:/docs squidfunk/mkdocs-material serve -a 0.0.0.0:8000