forked from juicedata/juicefs-csi-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
155 lines (130 loc) · 4.95 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
# Copyright 2018 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.
IMAGE?=juicedata/juicefs-csi-driver
REGISTRY?=docker.io
TARGETARCH?=amd64
VERSION=$(shell git describe --tags --match 'v*' --always --dirty)
GIT_BRANCH?=$(shell git rev-parse --abbrev-ref HEAD)
GIT_COMMIT?=$(shell git rev-parse HEAD)
DEV_TAG=dev-$(shell git describe --always --dirty)
BUILD_DATE?=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
PKG=github.com/juicedata/juicefs-csi-driver
LDFLAGS?="-X ${PKG}/pkg/driver.driverVersion=${VERSION} -X ${PKG}/pkg/driver.gitCommit=${GIT_COMMIT} -X ${PKG}/pkg/driver.buildDate=${BUILD_DATE} -s -w"
GO111MODULE=on
GOPROXY?=https://goproxy.io
GOPATH=$(shell go env GOPATH)
GOOS=$(shell go env GOOS)
GOBIN=$(shell pwd)/bin
.PHONY: juicefs-csi-driver
juicefs-csi-driver:
mkdir -p bin
CGO_ENABLED=0 GOOS=linux go build -ldflags ${LDFLAGS} -o bin/juicefs-csi-driver ./cmd/
.PHONY: verify
verify:
./hack/verify-all
.PHONY: test
test:
go test -gcflags=all=-l -v -race -cover ./pkg/... -coverprofile=cov1.out
.PHONY: test-sanity
test-sanity:
go test -v -cover ./tests/sanity/... -coverprofile=cov2.out
.PHONY: dashboard-dist
dashboard-dist:
cd dashboard-ui && yarn run build
.PHONY: dashboard
dashboard:
mkdir -p bin
go build -tags=jsoniter -ldflags ${LDFLAGS} -o bin/juicefs-csi-dashboard ./cmd/dashboard/
.PHONY: dashboard-dev
dashboard-dev: dashboard
./bin/juicefs-csi-dashboard -v=6 --dev --static-dir=./dashboard-ui/dist
.PHONY: dashboard-image
dashboard-image:
docker build --build-arg HTTP_PROXY=$(HTTP_PROXY) --build-arg HTTPS_PROXY=$(HTTPS_PROXY) --build-arg GOPROXY=$(GOPROXY) \
-t $(REGISTRY)/juicedata/csi-dashboard:$(VERSION) -f docker/dashboard.Dockerfile .
# build deploy yaml
yaml:
echo "# DO NOT EDIT: generated by 'kustomize build'" > deploy/k8s.yaml
kustomize build deploy/kubernetes/release >> deploy/k8s.yaml
cp deploy/k8s.yaml deploy/k8s_before_v1_18.yaml
sed -i.orig '[email protected]/[email protected]/v1beta1@g' deploy/k8s_before_v1_18.yaml
echo "# DO NOT EDIT: generated by 'kustomize build'" > deploy/webhook.yaml
kustomize build deploy/kubernetes/webhook >> deploy/webhook.yaml
echo "# DO NOT EDIT: generated by 'kustomize build'" > deploy/webhook-with-certmanager.yaml
kustomize build deploy/kubernetes/webhook-with-certmanager >> deploy/webhook-with-certmanager.yaml
./hack/update_install_script.sh
.PHONY: deploy
deploy: yaml
kubectl apply -f $<
.PHONY: deploy-delete
uninstall: yaml
kubectl delete -f $<
# build dev image
.PHONY: image-dev
image-dev: juicefs-csi-driver
docker build --build-arg TARGETARCH=$(TARGETARCH) -t $(IMAGE):$(DEV_TAG) -f docker/dev.Dockerfile bin
# push dev image
.PHONY: push-dev
push-dev:
ifeq ("$(DEV_K8S)", "microk8s")
docker image save -o juicefs-csi-driver-$(DEV_TAG).tar $(IMAGE):$(DEV_TAG)
sudo microk8s.ctr image import juicefs-csi-driver-$(DEV_TAG).tar
rm -f juicefs-csi-driver-$(DEV_TAG).tar
else ifeq ("$(DEV_K8S)", "kubeadm")
docker tag $(IMAGE):$(DEV_TAG) $(DEV_REGISTRY):$(DEV_TAG)
docker push $(DEV_REGISTRY):$(DEV_TAG)
else
minikube cache add $(IMAGE):$(DEV_TAG)
endif
.PHONY: deploy-dev/kustomization.yaml
deploy-dev/kustomization.yaml:
mkdir -p $(@D)
touch $@
cd $(@D); kustomize edit add resource ../deploy/kubernetes/release;
ifeq ("$(DEV_K8S)", "kubeadm")
cd $(@D); kustomize edit set image juicedata/juicefs-csi-driver=$(DEV_REGISTRY):$(DEV_TAG)
else
cd $(@D); kustomize edit set image juicedata/juicefs-csi-driver=:$(DEV_TAG)
endif
deploy-dev/k8s.yaml: deploy-dev/kustomization.yaml deploy/kubernetes/release/*.yaml
echo "# DO NOT EDIT: generated by 'kustomize build $(@D)'" > $@
kustomize build $(@D) >> $@
# Add .orig suffix only for compactiblity on macOS
ifeq ("$(DEV_K8S)", "microk8s")
sed -i 's@/var/lib/kubelet@/var/snap/microk8s/common/var/lib/kubelet@g' $@
endif
ifeq ("$(DEV_K8S)", "kubeadm")
sed -i.orig 's@juicedata/juicefs-csi-driver.*$$@$(DEV_REGISTRY):$(DEV_TAG)@g' $@
else
sed -i.orig 's@juicedata/juicefs-csi-driver.*$$@juicedata/juicefs-csi-driver:$(DEV_TAG)@g' $@
endif
.PHONY: deploy-dev
deploy-dev: deploy-dev/k8s.yaml
kapp deploy --app juicefs-csi-driver --file $<
.PHONY: delete-dev
delete-dev: deploy-dev/k8s.yaml
kapp delete --app juicefs-csi-driver
.PHONY: install-dev
install-dev: verify test image-dev push-dev deploy-dev/k8s.yaml deploy-dev
bin/mockgen: | bin
go install github.com/golang/mock/[email protected]
mockgen: bin/mockgen
./hack/update-gomock
npm-install:
npm install
npm ci
check-docs:
npm run markdown-lint
autocorrect --fix ./docs/
npm run check-broken-link