-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
127 lines (95 loc) · 4.03 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
E2E_TEST_SELECTOR=TestCreateCluster
NS=test
TEST_APP=galera
KUBEHOST=192.168.124.10
IMAGE_REPO=quay.io
IMAGE_USER=beekhof
IMAGE=$(IMAGE_REPO)/$(IMAGE_USER)/rss-operator:latest
IMAGE_STATUS=https://$(IMAGE_REPO)/repository/$(IMAGE_USER)/rss-operator/status
PROJECT=github.com/beekhof/rss-operator
DOCKER_REPO_ROOT="/go/src/$(PROJECT)"
GIT_SHA=$(shell git rev-parse --short HEAD || echo GitNotFound)
export KUBECONFIG=$(HOME)/.kube/config
export GOPATH=$(HOME)/go
export GREP=grep --color=never
PKGS=$(shell go list ./cmd/... ./pkg/... | grep -v -e generated -e apis/clusterlabs/v1alpha1)
TEST_PKGS=$(shell go list ./test/... | grep -v -e generated -e apis/clusterlabs/v1alpha1)
GENERATE_CMD=docker run --rm -v "$(PWD):$(DOCKER_REPO_ROOT)" -w "$(DOCKER_REPO_ROOT)" gcr.io/coreos-k8s-scale-testing/codegen /go/src/k8s.io/code-generator/generate-groups.sh all $(PROJECT)/pkg/generated $(PROJECT)/pkg/apis clusterlabs:v1alpha1 --go-header-file "./boilerplate.go.txt"
simple:
$(GOPATH)/bin/gosimple $(PKGS)
build:
hack/build/operator/build
gitpush:
git push
wait:
date
@echo "Waiting for the container to build..."
sleep 5
-while [ "x$$(curl -s $(IMAGE_STATUS) | tr '<' '\n' | grep -v -e '>$$' -e '^/' | sed 's/.*>//' | tail -n 1)" = xbuilding ]; do sleep 50; /bin/echo -n .; done
curl -s $(IMAGE_STATUS) | tr '<' '\n' | grep -v -e ">$$" -e '^/' | sed 's/.*>//' | tail -n 1
date
push: dockerfile-checks gitpush wait
test-quick:
gosimple $(TEST_PKGS)
publish: check build
@echo "building container..."
docker build --tag "${IMAGE}" -f hack/build/Dockerfile .
@echo "Uploading to $(IMAGE)"
docker push $(IMAGE)
@echo "upload complete"
# Called from Dockerfile
install: dockerfile-checks build
cp _output/bin/rss-operator /usr/local/bin/rss-operator
all: build push e2e-clean e2e
clean: e2e-clean
e2e-clean:
# Delete stuff, wait for the pods to die, then delete the entire namespace
-ssh root@$(KUBEHOST) -- kubectl -n $(NS) delete rss --all
-kubectl -n $(NS) delete crd,deploy,rs,rss,sts,svc,pods --all
while [ "x$$(kubectl -n $(NS) get po 2>/dev/null)" != "x" ]; do sleep 5; /bin/echo -n .; done
-kubectl delete ns/$(NS) clusterrole/$(NS)-operator clusterrolebinding/$(NS)-operator
while [ "x$$(kubectl get ns $(NS) 2>/dev/null)" != "x" ]; do sleep 5; /bin/echo -n .; done
e2e: test-quick e2e-clean
@echo "Running tests: $(E2E_TEST_SELECTOR)"
PASSES=e2e TEST_NAMESPACE=$(NS) OPERATOR_IMAGE=$(IMAGE) E2E_TEST_SELECTOR="$(E2E_TEST_SELECTOR)" hack/test
generated:
-rm -rf pkg/generated
-find pkg -name zz_generated.deepcopy.go #delete
$(GENERATE_CMD)
dockerfile-checks: deps fmt unused simple
check: fmt unused simple verify-generated
verify-generated:
$(GENERATE_CMD) --verify-only
fmt:
@echo "Checking gofmt..."
for file in $(shell ./go-list.sh); do o=`gofmt -l -s -d $$file`; if [ "x$$o" != x ]; then echo "$$o"; exit 1; fi; done
unused:
@echo "Checking unused..."
$(GOPATH)/bin/unused $(PKGS)
init: target deps generated all
apps:
make -C apps/galera all
make -C apps/dummy all
deps:
go get honnef.co/go/tools/cmd/gosimple
go get honnef.co/go/tools/cmd/unused
#glide install --strip-vendor
ns:
-kubectl create ns $(NS)
example/rbac/create_role.sh --namespace $(NS) --role-name $(NS)-operator --role-binding-name $(NS)-operator
# -kubectl -n $(NS) create clusterrolebinding $(NS)-everything --clusterrole=cluster-admin --serviceaccount=$(NS):default
galera:
make TEST_APP=$@ NS=$@ clean test
dummy:
make TEST_APP=$@ NS=$@ clean test
test: ns
@echo "Loading apps/$(TEST_APP)/cluster.yaml into $(NS)"
kubectl -n $(NS) create -f example/crd.yaml
-kubectl -n $(NS) create -f example/storage.yaml
kubectl -n $(NS) create -f example/deployment-operator.yaml
@echo "Waiting for the operator to become active"
while [ "x$$(kubectl -n $(NS) get po | grep rss-operator.*Running)" = x ]; do sleep 5; /bin/echo -n .; done
kubectl -n $(NS) get po | $(GREP) rss-operator | awk '{print $$1}'
kubectl -n $(NS) create -f apps/$(TEST_APP)/cluster.yaml
kubectl -n $(NS) logs -f $$(kubectl -n $(NS) get po | $(GREP) rss-operator | awk '{print $$1}')
.PHONY: test