-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
175 lines (131 loc) · 4.61 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
APP_VERSION ?= 0.0.1
-include Makevars.mk
-include Manifests.mk
###
# Building
###
.PHONY: build
build: build-operator
# Build all images
build-all: build-operator build-emulator build-adbmon build-goredir
# Same as build
build-operator: generate
docker build . \
-f build/operatorDockerfile \
-t ${OPERATOR_IMAGE} \
--build-arg GIT_COMMIT=`git rev-parse HEAD`
# Build an emulator image
.PHONY: build-emulator
build-emulator:
mkdir -p build/apps
docker build . \
-f build/emulatorDockerfile \
-t ${EMULATOR_IMAGE} \
--build-arg PLATFORM=${EMULATOR_PLATFORM} \
--build-arg CLI_TOOLS_VERSION=${EMULATOR_CLI_TOOLS}
# Build the adbmon image
build-adbmon:
docker build . \
-f build/adbmonDockerfile \
-t ${ADB_IMAGE} \
--build-arg ANDROID_TOOLS_VERSION=${ANDROID_TOOLS_VERSION}
# Build the goredir image
build-goredir:
docker build . \
-f build/goredirDockerfile \
-t ${REDIR_IMAGE}
###
# Push images
###
push: build-operator push-operator
push-operator: build-operator
docker push ${OPERATOR_IMAGE}
push-emulator: build-emulator
docker push ${EMULATOR_IMAGE}
push-adbmon: build-adbmon
docker push ${ADB_IMAGE}
push-goredir: build-goredir
docker push ${REDIR_IMAGE}
push-all: push-operator push-emulator push-adbmon push-goredir
###
# Codegen
###
# Ensures a local copy of the operator-sdk
${OPERATOR_SDK}:
mkdir -p _bin
curl -JL -o ${OPERATOR_SDK} ${OPERATOR_SDK_URL}
chmod +x ${OPERATOR_SDK}
# Generates deep copy code
generate: ${OPERATOR_SDK}
GOROOT=${GOROOT} ${OPERATOR_SDK} generate k8s --verbose
# Generates CRD manifest
manifests: ${OPERATOR_SDK}
${OPERATOR_SDK} generate crds --verbose
###
# Linting
###
${GOLANGCI_LINT}:
mkdir -p $(dir ${GOLANGCI_LINT})
cd $(dir ${GOLANGCI_LINT}) && curl -JL ${GOLANGCI_DOWNLOAD_URL} | tar xzf -
chmod +x $(dir ${GOLANGCI_LINT})golangci-lint-${GOLANGCI_VERSION}-$(shell uname | tr A-Z a-z)-amd64/golangci-lint
ln -s golangci-lint-${GOLANGCI_VERSION}-$(shell uname | tr A-Z a-z)-amd64/golangci-lint ${GOLANGCI_LINT}
# Lint files
lint: ${GOLANGCI_LINT}
${GOLANGCI_LINT} run -v --timeout 300s
# Tests
test:
echo 'no tests yet, but needed'
###
# Kind helpers for local testing
###
# Ensures a repo-local installation of kind
${KIND}:
mkdir -p $(dir ${KIND})
curl -JL -o ${KIND} ${KIND_DOWNLOAD_URL}
chmod +x ${KIND}
# Make a local test cluster and load a pre-baked emulator image into it
test-cluster: ${KIND}
echo "$$KIND_CLUSTER_MANIFEST" | ${KIND} create cluster --config - --image kindest/node:${KUBERNETES_VERSION}
$(MAKE) test-ingress
# Loads the operator image into the local kind cluster
load: load-operator
load-operator: ${KIND} build
${KIND} load docker-image ${OPERATOR_IMAGE}
# Loads the emulator into the kind cluster
load-emulator: ${KIND}
${KIND} load docker-image ${EMULATOR_IMAGE}
# Load adbmon image
load-adbmon: ${KIND}
${KIND} load docker-image ${ADB_IMAGE}
load-goredir:
${KIND} load docker-image ${REDIR_IMAGE}
load-all: load-operator load-emulator load-adbmon load-goredir
# Deploys metallb load balancer to the kind cluster
test-ingress:
kubectl --context kind-kind apply -f https://raw.githubusercontent.com/google/metallb/${METALLB_VERSION}/manifests/namespace.yaml
kubectl --context kind-kind apply -f https://raw.githubusercontent.com/google/metallb/${METALLB_VERSION}/manifests/metallb.yaml
kubectl --context kind-kind create secret generic -n metallb-system memberlist --from-literal=secretkey="`openssl rand -base64 128`" || echo
echo "$$METALLB_CONFIG" | kubectl --context kind-kind apply -f -
CERT_MANAGER_VERSION ?= v0.14.1
test-certmanager:
kubectl apply --context kind-kind --validate=false -f https://github.com/jetstack/cert-manager/releases/download/${CERT_MANAGER_VERSION}/cert-manager.yaml
kubectl --context kind-kind wait pod -l app=webhook -n cert-manager --for=condition=Ready
echo "$$SELF_SIGNER" | kubectl apply --context kind-kind -f -
# Builds and deploys the operator into a local kind cluster, requires helm.
.PHONY: deploy
deploy:
helm install --kube-context kind-kind android-farm-operator deploy/charts/android-farm-operator ${HELM_ARGS} --wait
example-farm:
kubectl apply --context kind-kind -f deploy/examples/example-config.yaml -f deploy/examples/example-farm.yaml
## Doc generation
${REFDOCS_CLONE}:
mkdir -p $(dir ${REFDOCS})
git clone https://github.com/ahmetb/gen-crd-api-reference-docs "${REFDOCS_CLONE}"
${REFDOCS}: ${REFDOCS_CLONE}
cd "${REFDOCS_CLONE}" && go build .
mv "${REFDOCS_CLONE}/gen-crd-api-reference-docs" "${REFDOCS}"
api-docs: ${REFDOCS}
go mod vendor
bash hack/update-api-docs.sh
# just do everything
all-of-it: lint generate manifests api-docs build-all test-cluster load-all deploy example-farm