forked from cert-manager/webhook-example
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
56 lines (40 loc) · 2.14 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
GO ?= $(shell which go)
OS ?= $(shell $(GO) env GOOS)
ARCH ?= $(shell $(GO) env GOARCH)
CWD = $(shell pwd)
IMAGE_NAME := "csp33/cert-manager-duckdns-webhook"
IMAGE_TAG := "latest"
OUT := $(shell pwd)/_out
KUBEBUILDER_VERSION=1.28.0
HELM_FILES := $(shell find chart/cert-manager-duckdns-webhook)
check-env:
@test $${DUCKDNS_DOMAIN?Please set environment variable DUCKDNS_DOMAIN}
@test $${DUCKDNS_TOKEN?Please set environment variable DUCKDNS_TOKEN}
setup-env: check-env
@rm -rf testdata;
@cp -R testdata.example testdata;
@sed -i "" "s/\DUCKDNS_TOKEN/${DUCKDNS_TOKEN}/g" testdata/duckdns-solver/secret.yaml;
test: _test/kubebuilder-$(KUBEBUILDER_VERSION)-$(OS)-$(ARCH)/etcd _test/kubebuilder-$(KUBEBUILDER_VERSION)-$(OS)-$(ARCH)/kube-apiserver _test/kubebuilder-$(KUBEBUILDER_VERSION)-$(OS)-$(ARCH)/kubectl setup-env
DUCKDNS_DOMAIN_URL=$(DUCKDNS_DOMAIN).duckdns.org \
TEST_ASSET_ETCD=$(CWD)/_test/kubebuilder-$(KUBEBUILDER_VERSION)-$(OS)-$(ARCH)/etcd \
TEST_ASSET_KUBE_APISERVER=$(CWD)/_test/kubebuilder-$(KUBEBUILDER_VERSION)-$(OS)-$(ARCH)/kube-apiserver \
TEST_ASSET_KUBECTL=$(CWD)/_test/kubebuilder-$(KUBEBUILDER_VERSION)-$(OS)-$(ARCH)/kubectl \
$(GO) test -v ./src
_test/kubebuilder-$(KUBEBUILDER_VERSION)-$(OS)-$(ARCH).tar.gz: | _test
curl -fsSL https://go.kubebuilder.io/test-tools/$(KUBEBUILDER_VERSION)/$(OS)/$(ARCH) -o $@
_test/kubebuilder-$(KUBEBUILDER_VERSION)-$(OS)-$(ARCH)/etcd _test/kubebuilder-$(KUBEBUILDER_VERSION)-$(OS)-$(ARCH)/kube-apiserver _test/kubebuilder-$(KUBEBUILDER_VERSION)-$(OS)-$(ARCH)/kubectl: _test/kubebuilder-$(KUBEBUILDER_VERSION)-$(OS)-$(ARCH).tar.gz | _test/kubebuilder-$(KUBEBUILDER_VERSION)-$(OS)-$(ARCH)
tar xfO $< kubebuilder/bin/$(notdir $@) > $@ && chmod +x $@
.PHONY: clean
clean:
rm -r _test $(OUT)
.PHONY: build
.PHONY: rendered-manifest.yaml
rendered-manifest.yaml: $(OUT)/rendered-manifest.yaml
$(OUT)/rendered-manifest.yaml: $(HELM_FILES) | $(OUT)
helm template \
--name example-webhook \
--set image.repository=$(IMAGE_NAME) \
--set image.tag=$(IMAGE_TAG) \
deploy/example-webhook > $@
_test $(OUT) _test/kubebuilder-$(KUBEBUILDER_VERSION)-$(OS)-$(ARCH):
mkdir -p $@