-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
88 lines (76 loc) · 3.65 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
PKG=github.com/capitalonline/cds-csi-driver
IMAGE?=registry-bj.capitalonline.net/cck/cds-csi-driver
IMAGE_OVERSEA=capitalonline/cds-csi-driver
VERSION=v2.1.4
GIT_COMMIT?=$(shell git rev-parse HEAD)
BUILD_DATE?=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS?="-X ${PKG}/pkg/common.version=${VERSION} -X ${PKG}/pkg/common.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/common.buildDate=${BUILD_DATE} -s -w"
NAS_DEPLOY_PATH=./deploy/nas
NAS_KUSTOMIZATION_RELEASE_PATH=${NAS_DEPLOY_PATH}/overlays/release
NAS_KUSTOMIZATION_TEST_PATH=${NAS_DEPLOY_PATH}/overlays/test
NAS_KUSTOMIZATION_FILE=${NAS_KUSTOMIZATION_RELEASE_PATH}/kustomization.yaml
OSS_DEPLOY_PATH=./deploy/oss
OSS_KUSTOMIZATION_RELEASE_PATH=${OSS_DEPLOY_PATH}/overlays/release
OSS_KUSTOMIZATION_TEST_PATH=${OSS_DEPLOY_PATH}/overlays/test
OSS_KUSTOMIZATION_FILE=${OSS_KUSTOMIZATION_RELEASE_PATH}/kustomization.yaml
DISK_DEPLOY_PATH=./deploy/disk
DISK_KUSTOMIZATION_RELEASE_PATH=${DISK_DEPLOY_PATH}/overlays/release
DISK_KUSTOMIZATION_TEST_PATH=${DISK_DEPLOY_PATH}/overlays/test
DISK_KUSTOMIZATION_FILE=${DISK_KUSTOMIZATION_RELEASE_PATH}/kustomization.yaml
EBS_DISK_DEPLOY_PATH=./deploy/ebs_disk
EBS_DISK_KUSTOMIZATION_RELEASE_PATH=${EBS_DISK_DEPLOY_PATH}/overlays/release
EBS_DISK_KUSTOMIZATION_TEST_PATH=${EBS_DISK_DEPLOY_PATH}/overlays/test
EBS_DISK_KUSTOMIZATION_FILE=${EBS_DISK_KUSTOMIZATION_RELEASE_PATH}/kustomization.yaml
.EXPORT_ALL_VARIABLES:
.PHONY: build
build:
mkdir -p bin
CGO_ENABLED=0 go build -ldflags ${LDFLAGS} -o bin/cds-csi-driver ./cmd/
.PHONY: container-binary
container-binary:
CGO_ENABLED=0 GOARCH="amd64" GOOS="linux" go build -ldflags ${LDFLAGS} -o /cds-csi-driver ./cmd/
.PHONY: image-release
image-release:
docker build -t $(IMAGE):$(VERSION) .
docker tag $(IMAGE):$(VERSION) $(IMAGE_OVERSEA):$(VERSION)
.PHONY: image
image:
docker build -t $(IMAGE):latest .
.PHONY: release
release: image-release
docker push $(IMAGE):$(VERSION)
docker push $(IMAGE_OVERSEA):$(VERSION)
.PHONY: sync-version
sync-version:
sed -i.bak 's/newTag: .*/newTag: '${VERSION}'/g' ${NAS_KUSTOMIZATION_FILE} && rm ${NAS_KUSTOMIZATION_FILE}.bak
sed -i.bak 's/newTag: .*/newTag: '${VERSION}'/g' ${OSS_KUSTOMIZATION_FILE} && rm ${OSS_KUSTOMIZATION_FILE}.bak
sed -i.bak 's/newTag: .*/newTag: '${VERSION}'/g' ${DISK_KUSTOMIZATION_FILE} && rm ${DISK_KUSTOMIZATION_FILE}.bak
.PHONY: kustomize
kustomize:sync-version
kubectl kustomize ${NAS_KUSTOMIZATION_RELEASE_PATH} > ${NAS_DEPLOY_PATH}/deploy.yaml
kubectl kustomize ${OSS_KUSTOMIZATION_RELEASE_PATH} > ${OSS_DEPLOY_PATH}/deploy.yaml
kubectl kustomize ${DISK_KUSTOMIZATION_RELEASE_PATH} > ${DISK_DEPLOY_PATH}/deploy.yaml
.PHONY: unit-test
unit-test:
@echo "**************************** running unit test ****************************"
go test -v -race ./pkg/...
.PHONY: test-prerequisite
test-prerequisite:
docker build -t $(IMAGE):test . && docker push $(IMAGE):test
kubectl kustomize ${NAS_KUSTOMIZATION_TEST_PATH} | kubectl apply -f -
kubectl kustomize ${OSS_KUSTOMIZATION_TEST_PATH} | kubectl apply -f -
kubectl kustomize ${DISK_KUSTOMIZATION_TEST_PATH} | kubectl apply -f -
.PHONY: integration-test
integration-test:
@echo "**************************** running integration test ****************************"
@./test.sh
.PHONE: test
test: unit-test integration-test
@echo "**************************** all tests passed ****************************"
.PHONE: oss-test
oss-test:
@echo "**************************** running oss unit test ****************************"
go test -v -race ./pkg/driver/oss/...
@echo "**************************** running oss integration test ****************************"
@./test/oss/test.sh
@echo "**************************** all tests passed ****************************"