-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
69 lines (53 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
57
58
59
60
61
62
63
64
65
66
67
68
69
PKG=github.com/mgoltzsche/ktransform
TEST_IMAGE=ktransform-test
TEST_NAMESPACE=ktransform-test-$(shell date '+%Y%m%d-%H%M%S')
define TESTDOCKERFILE
FROM $(TEST_IMAGE)
ENV K8S_VERSION=v1.18.5
RUN apk add --update --no-cache git \
&& curl -fsSLo /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/$${K8S_VERSION}/bin/linux/amd64/kubectl \
&& chmod +x /usr/local/bin/kubectl
endef
export TESTDOCKERFILE
all: operator
operator:
docker build --force-rm -t image-registry-operator -f build/Dockerfile --target=operator .
containerized-unit-tests:
docker build --force-rm -f build/Dockerfile .
unit-tests:
go test -v ./pkg/...
containerized-%: test-image
$(eval DOCKER ?= $(if $(shell docker -v),docker,podman))
$(eval DOPTS := $(if $(wildcard $(HOME)/.minikube),-v $(HOME)/.minikube:$(HOME)/.minikube,))
$(DOCKER) run --rm --net host \
-v "`pwd`:/go/src/$(PKG)" \
--mount "type=bind,src=$$KUBECONFIG,dst=/root/.kube/config" \
$(DOPTS) \
--entrypoint /bin/sh $(TEST_IMAGE) -c "make $*"
test-image:
docker build --force-rm -t $(TEST_IMAGE) -f build/Dockerfile --target=builddeps .
echo "$$TESTDOCKERFILE" | docker build --force-rm -t $(TEST_IMAGE) -f - .
generate:
#operator-sdk add api --api-version=ktransform.mgoltzsche.github.com/v1alpha1 --kind=SecretTransform
#operator-sdk add controller --api-version=ktransform.mgoltzsche.github.com/v1alpha1 --kind=SecretTransform
operator-sdk generate k8s
operator-sdk generate crds
e2e-tests: operatorsdk-tests-local
operatorsdk-tests-local:
kubectl create namespace $(TEST_NAMESPACE)-local
operator-sdk test local ./test/e2e --operator-namespace $(TEST_NAMESPACE)-local --up-local; \
STATUS=$$?; \
kubectl delete namespace $(TEST_NAMESPACE)-local; \
exit $$STATUS
operatorsdk-tests:
operator-sdk test local ./test/e2e
install-tools: download-deps
cat tools.go | grep -E '^\s*_' | cut -d'"' -f2 | xargs -n1 go install
download-deps:
go mod download
clean:
rm -rf build/_output .kubeconfig
start-minikube:
minikube start --kubernetes-version=1.18.5 --network-plugin=cni --enable-default-cni --container-runtime=cri-o --bootstrapper=kubeadm
delete-minikube:
minikube delete