forked from kubernetes-sigs/azuredisk-csi-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
154 lines (136 loc) · 5.25 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
# Copyright 2017 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.
PKG = sigs.k8s.io/azuredisk-csi-driver
GIT_COMMIT ?= $(shell git rev-parse HEAD)
REGISTRY ?= andyzhangx
REGISTRY_NAME ?= $(shell echo $(REGISTRY) | sed "s/.azurecr.io//g")
DRIVER_NAME = disk.csi.azure.com
IMAGE_NAME ?= azuredisk-csi
IMAGE_VERSION ?= v0.8.0
# Use a custom version for E2E tests if we are testing in CI
ifdef CI
ifndef PUBLISH
override IMAGE_VERSION := e2e-$(GIT_COMMIT)
endif
endif
IMAGE_TAG ?= $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_VERSION)
IMAGE_TAG_LATEST = $(REGISTRY)/$(IMAGE_NAME):latest
REV = $(shell git describe --long --tags --dirty)
BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
TOPOLOGY_KEY = topology.$(DRIVER_NAME)/zone
ENABLE_TOPOLOGY ?= false
LDFLAGS ?= "-X ${PKG}/pkg/azuredisk.driverVersion=${IMAGE_VERSION} -X ${PKG}/pkg/azuredisk.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/azuredisk.buildDate=${BUILD_DATE} -X ${PKG}/pkg/azuredisk.DriverName=${DRIVER_NAME} -X ${PKG}/pkg/azuredisk.topologyKey=${TOPOLOGY_KEY} -extldflags "-static""
GINKGO_FLAGS = -ginkgo.noColor -ginkgo.v
ifeq ($(ENABLE_TOPOLOGY), true)
GINKGO_FLAGS += -ginkgo.focus="\[multi-az\]"
else
GINKGO_FLAGS += -ginkgo.focus="\[single-az\]"
endif
GOPATH ?= $(shell go env GOPATH)
GOBIN ?= $(GOPATH)/bin
GO111MODULE = off
DOCKER_CLI_EXPERIMENTAL = enabled
export GOPATH GOBIN GO111MODULE DOCKER_CLI_EXPERIMENTAL
.PHONY: all
all: azuredisk
.PHONY: verify
verify: unit-test
hack/verify-all.sh
go vet ./pkg/...
.PHONY: unit-test
unit-test:
go test -v -cover ./pkg/... ./test/utils/credentials
.PHONY: sanity-test
sanity-test: azuredisk
go test -v -timeout=30m ./test/sanity
.PHONY: integration-test
integration-test: azuredisk
go test -v -timeout=30m ./test/integration
.PHONY: e2e-test
e2e-test:
go test -v -timeout=0 ./test/e2e ${GINKGO_FLAGS}
.PHONY: e2e-bootstrap
e2e-bootstrap: install-helm
docker pull $(IMAGE_TAG) || make azuredisk-container push
ifdef TEST_WINDOWS
helm install azuredisk-csi-driver charts/latest/azuredisk-csi-driver --namespace kube-system --wait --timeout=15m -v=5 --debug \
--set image.azuredisk.repository=$(REGISTRY)/$(IMAGE_NAME) \
--set image.azuredisk.tag=$(IMAGE_VERSION) \
--set windows.enabled=true \
--set linux.enabled=false \
--set controller.replicas=1
else
helm install azuredisk-csi-driver charts/latest/azuredisk-csi-driver --namespace kube-system --wait --timeout=15m -v=5 --debug \
--set image.azuredisk.repository=$(REGISTRY)/$(IMAGE_NAME) \
--set image.azuredisk.tag=$(IMAGE_VERSION) \
--set snapshot.enabled=true
endif
.PHONY: install-helm
install-helm:
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
.PHONY: e2e-teardown
e2e-teardown:
helm delete azuredisk-csi-driver --namespace kube-system
.PHONY: azuredisk
azuredisk:
CGO_ENABLED=0 GOOS=linux go build -a -ldflags ${LDFLAGS} -o _output/azurediskplugin ./pkg/azurediskplugin
.PHONY: azuredisk-windows
azuredisk-windows:
CGO_ENABLED=0 GOOS=windows go build -a -ldflags ${LDFLAGS} -o _output/azurediskplugin.exe ./pkg/azurediskplugin
.PHONY: container
container: azuredisk
docker build --no-cache -t $(IMAGE_TAG) -f ./pkg/azurediskplugin/dev.Dockerfile .
.PHONY: azuredisk-container
azuredisk-container:
docker buildx rm container-builder || true
docker buildx create --use --name=container-builder
ifdef CI
az acr login --name $(REGISTRY_NAME)
docker buildx build --no-cache --build-arg LDFLAGS=${LDFLAGS} -t $(IMAGE_TAG)-linux-amd64 -f ./pkg/azurediskplugin/Dockerfile --platform="linux/amd64" --push .
docker buildx build --no-cache --build-arg LDFLAGS=${LDFLAGS} -t $(IMAGE_TAG)-windows-1809-amd64 -f ./pkg/azurediskplugin/Windows.Dockerfile --platform="windows/amd64" --push .
docker manifest create $(IMAGE_TAG) $(IMAGE_TAG)-linux-amd64 $(IMAGE_TAG)-windows-1809-amd64
docker manifest inspect $(IMAGE_TAG)
ifdef PUBLISH
docker manifest create $(IMAGE_TAG_LATEST) $(IMAGE_TAG)-linux-amd64 $(IMAGE_TAG)-windows-1809-amd64
docker manifest inspect $(IMAGE_TAG_LATEST)
endif
else
ifdef TEST_WINDOWS
docker buildx build --no-cache --build-arg LDFLAGS=${LDFLAGS} -t $(IMAGE_TAG)-windows-1809-amd64 -f ./pkg/azurediskplugin/Windows.Dockerfile --platform="windows/amd64" --output "type=image" .
else
docker buildx build --no-cache --build-arg LDFLAGS=${LDFLAGS} -t $(IMAGE_TAG) -f ./pkg/azurediskplugin/Dockerfile --platform="linux/amd64" --output "type=docker,push=false" .
endif
endif
.PHONY: push
push:
ifdef CI
docker manifest push --purge $(IMAGE_TAG)
else
docker push $(IMAGE_TAG)
endif
.PHONY: push-latest
push-latest:
ifdef CI
docker manifest push --purge $(IMAGE_TAG_LATEST)
else
docker push $(IMAGE_TAG_LATEST)
endif
.PHONY: build-push
build-push: azuredisk-container
docker tag $(IMAGE_TAG) $(IMAGE_TAG_LATEST)
docker push $(IMAGE_TAG_LATEST)
.PHONY: clean
clean:
go clean -r -x
-rm -rf _output