-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
289 lines (228 loc) · 8.46 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# Copyright (c) Edgeless Systems GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# This file incorporates work covered by the following copyright and
# permission notice:
#
#
# Copyright 2023 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
VERSION?=v1.2.0
PKG=github.com/kubernetes-sigs/aws-ebs-csi-driver
GIT_COMMIT?=$(shell git rev-parse HEAD)
BUILD_DATE?=$(shell date -u -Iseconds)
LDFLAGS?="-X ${PKG}/pkg/driver.driverVersion=${VERSION} -X ${PKG}/pkg/cloud.driverVersion=${VERSION} -X ${PKG}/pkg/driver.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/driver.buildDate=${BUILD_DATE} -s -w"
OS?=$(shell go env GOHOSTOS)
ARCH?=$(shell go env GOHOSTARCH)
ifeq ($(OS),windows)
BINARY=aws-ebs-csi-driver.exe
OSVERSION?=ltsc2022
else
BINARY=aws-ebs-csi-driver
OSVERSION?=al2023
endif
GO_SOURCES=go.mod go.sum $(shell find pkg cmd -type f -name "*.go")
REGISTRY?=ghcr.io/edgelesssys/constellation
IMAGE?=$(REGISTRY)/aws-csi-driver
DRIVERVERSION=$(VERSION)
TAG?=$(GIT_COMMIT)
OUTPUT_TYPE?=docker
OS?=linux
ARCH?=amd64
OSVERSION?=al2023
ALL_OS?=linux
ALL_ARCH_linux?=amd64 arm64
ALL_OSVERSION_linux?=al2023
ALL_OS_ARCH_OSVERSION_linux=$(foreach arch, $(ALL_ARCH_linux), $(foreach osversion, ${ALL_OSVERSION_linux}, linux-$(arch)-${osversion}))
ALL_OS_ARCH_OSVERSION=$(foreach os, $(ALL_OS), ${ALL_OS_ARCH_OSVERSION_${os}})
CLUSTER_NAME?=ebs-csi-e2e.k8s.local
CLUSTER_TYPE?=kops
# split words on hyphen, access by 1-index
word-hyphen = $(word $2,$(subst -, ,$1))
.EXPORT_ALL_VARIABLES:
.PHONY: linux/$(ARCH) bin/aws-ebs-csi-driver
linux/$(ARCH): bin/aws-ebs-csi-driver
bin/aws-ebs-csi-driver: | bin
CGO_ENABLED=1 GOOS=linux GOARCH=$(ARCH) go build -mod=mod -ldflags ${LDFLAGS} -o bin/aws-ebs-csi-driver ./cmd/
.PHONY: clean
clean:
rm -rf bin/
.PHONY: test
test:
go test -v -race ./cmd/... ./pkg/...
.PHONY: test/coverage
test/coverage:
go test -coverprofile=cover.out ./cmd/... ./pkg/...
grep -v "mock" cover.out > filtered_cover.out
go tool cover -html=filtered_cover.out -o coverage.html
rm cover.out filtered_cover.out
# TODO: Re-enable sanity tests
# sanity tests have been disabled with the removal of NewFakeDriver, which was previously created to instantiate a fake driver utilized for testing.
# to re-enable tests, implement sanity tests creating a new driver instance by injecting mocked dependencies.
#.PHONY: test-sanity
#test-sanity:
# go test -v -race ./tests/sanity/...
.PHONY: tools
tools: bin/aws bin/ct bin/eksctl bin/ginkgo bin/golangci-lint bin/gomplate bin/helm bin/kops bin/kubetest2 bin/mockgen bin/shfmt
.PHONY: update
update: update/gofmt update/kustomize update/mockgen update/gomod update/shfmt
@echo "All updates succeeded!"
.PHONY: verify
verify: verify/govet verify/golangci-lint verify/update
@echo "All verifications passed!"
# Builds all linux images and pushes them
.PHONY: all-push
all-push: all-image-registry push-manifest
.PHONY: cluster/create
cluster/create: bin/kops bin/eksctl bin/aws bin/gomplate
./hack/e2e/create-cluster.sh
.PHONY: cluster/kubeconfig
cluster/kubeconfig:
@./hack/e2e/kubeconfig.sh
.PHONY: cluster/image
cluster/image: bin/aws
./hack/e2e/build-image.sh
.PHONY: cluster/delete
cluster/delete: bin/kops bin/eksctl
./hack/e2e/delete-cluster.sh
## E2E targets
# Targets to run e2e tests
.PHONY: e2e/single-az
e2e/single-az: bin/helm bin/ginkgo
AWS_AVAILABILITY_ZONES=us-west-2a \
TEST_PATH=./tests/e2e/... \
GINKGO_FOCUS="\[ebs-csi-e2e\] \[single-az\]" \
GINKGO_PARALLEL=5 \
HELM_EXTRA_FLAGS="--set=controller.volumeModificationFeature.enabled=true,sidecars.provisioner.additionalArgs[0]='--feature-gates=VolumeAttributesClass=true',sidecars.resizer.additionalArgs[0]='--feature-gates=VolumeAttributesClass=true'" \
./hack/e2e/run.sh
.PHONY: e2e/multi-az
e2e/multi-az: bin/helm bin/ginkgo
TEST_PATH=./tests/e2e/... \
GINKGO_FOCUS="\[ebs-csi-e2e\] \[multi-az\]" \
GINKGO_PARALLEL=5 \
./hack/e2e/run.sh
.PHONY: e2e/external
e2e/external: bin/helm bin/kubetest2
COLLECT_METRICS="true" \
./hack/e2e/run.sh
.PHONY: e2e/external-windows
e2e/external-windows: bin/helm bin/kubetest2
WINDOWS=true \
GINKGO_SKIP="\[Disruptive\]|\[Serial\]|\[LinuxOnly\]|\[Feature:VolumeSnapshotDataSource\]|\(xfs\)|\(ext4\)|\(block volmode\)" \
GINKGO_PARALLEL=15 \
EBS_INSTALL_SNAPSHOT="false" \
./hack/e2e/run.sh
.PHONY: e2e/external-windows-hostprocess
e2e/external-windows-hostprocess: bin/helm bin/kubetest2
WINDOWS_HOSTPROCESS=true \
WINDOWS=true \
GINKGO_SKIP="\[Disruptive\]|\[Serial\]|\[LinuxOnly\]|\[Feature:VolumeSnapshotDataSource\]|\(xfs\)|\(ext4\)|\(block volmode\)" \
GINKGO_PARALLEL=15 \
EBS_INSTALL_SNAPSHOT="false" \
./hack/e2e/run.sh
.PHONY: e2e/external-kustomize
e2e/external-kustomize: bin/kubetest2
DEPLOY_METHOD="kustomize" \
./hack/e2e/run.sh
.PHONY: e2e/helm-ct
e2e/helm-ct: bin/helm bin/ct
HELM_CT_TEST="true" \
./hack/e2e/run.sh
## Release scripts
# Targets run as part of performing a release
.PHONY: update-truth-sidecars
update-truth-sidecars: hack/release-scripts/get-latest-sidecar-images
./hack/release-scripts/get-latest-sidecar-images
.PHONY: generate-sidecar-tags
generate-sidecar-tags: update-truth-sidecars charts/aws-ebs-csi-driver/values.yaml deploy/kubernetes/overlays/stable/gcr/kustomization.yaml hack/release-scripts/generate-sidecar-tags
./hack/release-scripts/generate-sidecar-tags
.PHONY: update-sidecar-dependencies
update-sidecar-dependencies: update-truth-sidecars generate-sidecar-tags update/kustomize
## CI aliases
# Targets intended to be executed mostly or only by CI jobs
.PHONY: all-push-with-a1compat
all-push-with-a1compat: sub-image-linux-arm64-al2 all-image-registry push-manifest
test-e2e-%:
./hack/prow-e2e.sh test-e2e-$*
test-helm-chart:
./hack/prow-e2e.sh test-helm-chart
## Builds
bin:
@mkdir -p $@
.PHONY: all-image-registry
all-image-registry: $(addprefix sub-image-,$(ALL_OS_ARCH_OSVERSION))
sub-image-%:
$(MAKE) OS=$(call word-hyphen,$*,1) ARCH=$(call word-hyphen,$*,2) OSVERSION=$(call word-hyphen,$*,3) image
.PHONY: image
image: .image-$(TAG)-$(OS)-$(ARCH)-$(OSVERSION)
.image-$(TAG)-$(OS)-$(ARCH)-$(OSVERSION):
DOCKER_BUILDKIT=1 docker build \
--platform=$(OS)/$(ARCH) \
--progress=plain \
-t=$(IMAGE):$(DRIVERVERSION) \
--build-arg=GOPROXY=$(GOPROXY) \
--build-arg=VERSION=$(VERSION) \
.
.PHONY: create-manifest
create-manifest: all-image-registry
# sed expression:
# LHS: match 0 or more not space characters
# RHS: replace with $(IMAGE):$(TAG)-& where & is what was matched on LHS
docker manifest create --amend $(IMAGE):$(TAG) $(shell echo $(ALL_OS_ARCH_OSVERSION) | sed -e "s~[^ ]*~$(IMAGE):$(TAG)\-&~g")
.PHONY: push-manifest
push-manifest: create-manifest
docker manifest push --purge $(IMAGE):$(TAG)
## Tools
# Tools necessary to perform other targets
bin/%: hack/tools/install.sh hack/tools/python-runner.sh
@TOOLS_PATH="$(shell pwd)/bin" ./hack/tools/install.sh $*
## Updaters
# Automatic generators/formatters for code
.PHONY: update/gofmt
update/gofmt:
gofmt -s -w .
.PHONY: update/kustomize
update/kustomize: bin/helm
./hack/update-kustomize.sh
.PHONY: update/mockgen
update/mockgen: bin/mockgen
./hack/update-mockgen.sh
.PHONY: update/gomod
update/gomod:
go mod tidy
.PHONY: update/shfmt
update/shfmt: bin/shfmt
./bin/shfmt -w -i 2 -d ./hack/
## Verifiers
# Linters and similar
.PHONY: verify/golangci-lint
verify/golangci-lint: bin/golangci-lint
./bin/golangci-lint run --timeout=10m --verbose
.PHONY: verify/govet
verify/govet:
go vet $$(go list ./...)
.PHONY: verify/update
verify/update: bin/helm bin/mockgen
./hack/verify-update.sh