-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
63 lines (52 loc) · 1.86 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
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
OS ?= $(shell go env GOOS)
ARCH ?= $(shell go env GOARCH)
IMAGE_NAME := "dodopizza/cert-manager-webhook-yandex"
IMAGE_TAG := "latest"
K8S_VERSION=1.21.2
.PHONY: all
all: help
build:
docker buildx build --platform linux/$(ARCH) --tag $(IMAGE_NAME):$(IMAGE_TAG) .
.PHONY: tidy
tidy:
go mod tidy -compat=1.17 -v
.PHONY: lint
lint:
golangci-lint run
.PHONY: prepare
prepare: tidy lint
PHONY: test-unit
test-unit:
go test -v ./yandex
.PHONY: test-integration
test-integration: _test/kubebuilder
TEST_ASSET_ETCD=_test/kubebuilder/bin/etcd \
TEST_ASSET_KUBE_APISERVER=_test/kubebuilder/bin/kube-apiserver \
TEST_ASSET_KUBECTL=_test/kubebuilder/bin/kubectl \
go test -v .
_test/kubebuilder:
mkdir -p _test/kubebuilder
curl -sSLo envtest-bins.tar.gz "https://go.kubebuilder.io/test-tools/${K8S_VERSION}/${OS}/${ARCH}"
tar -C _test/kubebuilder --strip-components=1 -zvxf envtest-bins.tar.gz
rm envtest-bins.tar.gz
.PHONY: clean
clean:
rm -Rf _test/kubebuilder
.PHONY: help
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@echo " ${YELLOW}build ${RESET} Build docker image for specific arch"
@echo " ${YELLOW}tidy ${RESET} Run tidy for go module to remove unused dependencies"
@echo " ${YELLOW}lint ${RESET} Run linters via golangci-lint"
@echo " ${YELLOW}prepare ${RESET} Run all available checks and generators"
@echo " ${YELLOW}test-unit ${RESET} Run available unit tests"
@echo " ${YELLOW}test-integration ${RESET} Run integration test located at main_test.go"
@echo " ${YELLOW}clean ${RESET} Cleanup all temporary artifacts"