@@ -19,12 +19,6 @@ REPO := $(notdir $(shell pwd))
19
19
BIN := stash-mysql
20
20
COMPRESS ?= no
21
21
22
- # Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
23
- CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false,crdVersions={v1beta1,v1}"
24
- # https://github.com/appscodelabs/gengo-builder
25
- CODE_GENERATOR_IMAGE ?= appscode/gengo:release-1.18
26
- API_GROUPS ?= installer:v1alpha1
27
-
28
22
# Where to push the docker image.
29
23
REGISTRY ?= stashed
30
24
@@ -54,7 +48,7 @@ RESTIC_VER := 0.12.0
54
48
# ## These variables should not need tweaking.
55
49
# ##
56
50
57
- SRC_PKGS := apis cmd pkg
51
+ SRC_PKGS := cmd pkg
58
52
SRC_DIRS := $(SRC_PKGS ) # directories which hold app source (not vendored)
59
53
60
54
DOCKER_PLATFORMS := linux/amd64
@@ -76,7 +70,6 @@ TAG_DBG := $(VERSION)-dbg_$(OS)_$(ARCH)
76
70
77
71
GO_VERSION ?= 1.16
78
72
BUILD_IMAGE ?= appscode/golang-dev:$(GO_VERSION )
79
- CHART_TEST_IMAGE ?= quay.io/helmpack/chart-testing:v3.0.0
80
73
81
74
OUTBIN = bin/$(OS ) _$(ARCH ) /$(BIN )
82
75
ifeq ($(OS ) ,windows)
@@ -137,186 +130,9 @@ version:
137
130
@echo ::set-output name=commit_hash::$(commit_hash )
138
131
@echo ::set-output name=commit_timestamp::$(commit_timestamp )
139
132
140
- .PHONY : clientset
141
- clientset :
142
- @docker run --rm \
143
- -u $$(id -u ) :$$(id -g ) \
144
- -v /tmp:/.cache \
145
- -v $$(pwd ) :$(DOCKER_REPO_ROOT ) \
146
- -w $(DOCKER_REPO_ROOT ) \
147
- --env HTTP_PROXY=$(HTTP_PROXY ) \
148
- --env HTTPS_PROXY=$(HTTPS_PROXY ) \
149
- $(CODE_GENERATOR_IMAGE ) \
150
- /go/src/k8s.io/code-generator/generate-groups.sh \
151
- " deepcopy" \
152
- $(GO_PKG ) /$(REPO ) /client \
153
- $(GO_PKG ) /$(REPO ) /apis \
154
- " $( API_GROUPS) " \
155
- --go-header-file " ./hack/license/go.txt"
156
-
157
- # Generate openapi schema
158
- .PHONY : openapi
159
- openapi : $(addprefix openapi-, $(subst :,_, $(API_GROUPS ) ) )
160
- @echo " Generating api/openapi-spec/swagger.json"
161
- @docker run --rm \
162
- -u $$(id -u ) :$$(id -g ) \
163
- -v /tmp:/.cache \
164
- -v $$(pwd ) :$(DOCKER_REPO_ROOT ) \
165
- -w $(DOCKER_REPO_ROOT ) \
166
- --env HTTP_PROXY=$(HTTP_PROXY ) \
167
- --env HTTPS_PROXY=$(HTTPS_PROXY ) \
168
- --env GO111MODULE=on \
169
- --env GOFLAGS=" -mod=vendor" \
170
- $(BUILD_IMAGE ) \
171
- go run hack/gencrd/main.go
172
-
173
- openapi-% :
174
- @echo " Generating openapi schema for $( subst _,/,$* ) "
175
- @docker run --rm \
176
- -u $$(id -u ) :$$(id -g ) \
177
- -v /tmp:/.cache \
178
- -v $$(pwd ) :$(DOCKER_REPO_ROOT ) \
179
- -w $(DOCKER_REPO_ROOT ) \
180
- --env HTTP_PROXY=$(HTTP_PROXY ) \
181
- --env HTTPS_PROXY=$(HTTPS_PROXY ) \
182
- $(CODE_GENERATOR_IMAGE ) \
183
- openapi-gen \
184
- --v 1 --logtostderr \
185
- --go-header-file " ./hack/license/go.txt" \
186
- --input-dirs " $( GO_PKG) /$( REPO) /apis/$( subst _,/,$* ) ,k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/apimachinery/pkg/api/resource,k8s.io/apimachinery/pkg/runtime,k8s.io/apimachinery/pkg/util/intstr,k8s.io/apimachinery/pkg/version,k8s.io/api/core/v1,k8s.io/api/apps/v1,k8s.io/api/rbac/v1" \
187
- --output-package " $( GO_PKG) /$( REPO) /apis/$( subst _,/,$* ) " \
188
- --report-filename /tmp/violation_exceptions.list
189
-
190
- # Generate CRD manifests
191
- .PHONY : gen-crds
192
- gen-crds :
193
- @echo " Generating CRD manifests"
194
- @docker run --rm \
195
- -u $$(id -u ) :$$(id -g ) \
196
- -v /tmp:/.cache \
197
- -v $$(pwd ) :$(DOCKER_REPO_ROOT ) \
198
- -w $(DOCKER_REPO_ROOT ) \
199
- --env HTTP_PROXY=$(HTTP_PROXY ) \
200
- --env HTTPS_PROXY=$(HTTPS_PROXY ) \
201
- $(CODE_GENERATOR_IMAGE ) \
202
- controller-gen \
203
- $(CRD_OPTIONS ) \
204
- paths=" ./apis/..." \
205
- output:crd:artifacts:config=crds
206
-
207
- crds_to_patch := installer.stash.appscode.com_stashmysqls.yaml
208
-
209
- .PHONY : patch-crds
210
- patch-crds : $(addprefix patch-crd-, $(crds_to_patch ) )
211
- patch-crd-% : $(BUILD_DIRS )
212
- @echo " patching $* "
213
- @kubectl patch -f crds/$* -p " $$ (cat hack/crd-patch.json)" --type=json --local=true -o yaml > bin/$*
214
- @mv bin/$* crds/$*
215
-
216
- .PHONY : label-crds
217
- label-crds : $(BUILD_DIRS )
218
- @for f in crds/* .yaml; do \
219
- echo " applying app=stash label to $$ f" ; \
220
- kubectl label --overwrite -f $$ f --local=true -o yaml app=stash > bin/crd.yaml; \
221
- mv bin/crd.yaml $$ f; \
222
- done
223
-
224
- .PHONY : gen-crd-protos
225
- gen-crd-protos : $(addprefix gen-crd-protos-, $(subst :,_, $(API_GROUPS ) ) )
226
-
227
- gen-crd-protos-% :
228
- @echo " Generating protobuf for $( subst _,/,$* ) "
229
- @docker run --rm \
230
- -u $$(id -u ) :$$(id -g ) \
231
- -v /tmp:/.cache \
232
- -v $$(pwd ) :$(DOCKER_REPO_ROOT ) \
233
- -w $(DOCKER_REPO_ROOT ) \
234
- --env HTTP_PROXY=$(HTTP_PROXY ) \
235
- --env HTTPS_PROXY=$(HTTPS_PROXY ) \
236
- $(CODE_GENERATOR_IMAGE ) \
237
- go-to-protobuf \
238
- --go-header-file " ./hack/license/go.txt" \
239
- --proto-import=$(DOCKER_REPO_ROOT ) /vendor \
240
- --proto-import=$(DOCKER_REPO_ROOT ) /third_party/protobuf \
241
- --apimachinery-packages=-k8s.io/apimachinery/pkg/api/resource,-k8s.io/apimachinery/pkg/apis/meta/v1,-k8s.io/apimachinery/pkg/apis/meta/v1beta1,-k8s.io/apimachinery/pkg/runtime,-k8s.io/apimachinery/pkg/runtime/schema,-k8s.io/apimachinery/pkg/util/intstr \
242
- --packages=-k8s.io/api/core/v1,stash.appscode.dev/mysql/apis/$(subst _,/,$* )
243
-
244
- .PHONY : gen-bindata
245
- gen-bindata :
246
- @docker run \
247
- -i \
248
- --rm \
249
- -u $$(id -u ) :$$(id -g ) \
250
- -v $$(pwd ) :/src \
251
- -w /src/crds \
252
- -v /tmp:/.cache \
253
- --env HTTP_PROXY=$(HTTP_PROXY ) \
254
- --env HTTPS_PROXY=$(HTTPS_PROXY ) \
255
- $(BUILD_IMAGE ) \
256
- go-bindata -ignore=\\ .go -ignore=\\ .DS_Store -mode=0644 -modtime=1573722179 -o bindata.go -pkg crds ./...
257
-
258
- .PHONY : gen-values-schema
259
- gen-values-schema : $(BUILD_DIRS )
260
- @for dir in charts/* /; do \
261
- dir=$$ {dir%* /}; \
262
- dir=$$ {dir## */}; \
263
- crd=$$(echo $$dir | tr -d '-' ) ; \
264
- yq r crds/installer.stash.appscode.com_$$ {crd}s.yaml spec.versions[0].schema.openAPIV3Schema.properties.spec > bin/values.openapiv3_schema.yaml; \
265
- yq d bin/values.openapiv3_schema.yaml description > charts/$$ {dir}/values.openapiv3_schema.yaml; \
266
- rm -rf bin/values.openapiv3_schema.yaml; \
267
- done
268
-
269
- .PHONY : gen-readme
270
- gen-readme :
271
- @jq -n -c --arg v " $( CHART_VERSION) " ' {"version":$$v}' > /tmp/data.json
272
- @render-gotpl --template=hack/templates/readme.txt --data=/tmp/data.json > README.md
273
-
274
- .PHONY : gen-chart-doc
275
- gen-chart-doc : gen-chart-doc-stash-mysql
276
-
277
- gen-chart-doc-% :
278
- @echo " Generate $* chart docs"
279
- @docker run --rm \
280
- -u $$(id -u ) :$$(id -g ) \
281
- -v /tmp:/.cache \
282
- -v $$(pwd ) :$(DOCKER_REPO_ROOT ) \
283
- -w $(DOCKER_REPO_ROOT ) \
284
- --env HTTP_PROXY=$(HTTP_PROXY ) \
285
- --env HTTPS_PROXY=$(HTTPS_PROXY ) \
286
- $(BUILD_IMAGE ) \
287
- chart-doc-gen -d ./charts/$* /doc.yaml -v ./charts/$* /values.yaml > ./charts/$* /README.md
288
-
289
- .PHONY : manifests
290
- manifests : gen-crds gen-values-schema gen-chart-doc
291
-
292
133
.PHONY : gen
293
- gen : clientset manifests
294
-
295
- CHART_REGISTRY ?= appscode
296
- CHART_REGISTRY_URL ?= https://charts.appscode.com/stable/
297
- CHART_VERSION ?=
298
- APP_VERSION ?= $(CHART_VERSION )
299
-
300
- .PHONY : update-charts
301
- update-charts : $(shell find $$(pwd ) /charts -maxdepth 1 -mindepth 1 -type d -printf 'chart-% f ')
302
-
303
- chart-% :
304
- @$(MAKE ) chart-contents-$* gen-chart-doc-$* --no-print-directory
305
-
306
- chart-contents-% :
307
- @yq w -i ./charts/$* /doc.yaml repository.name --tag ' !!str' $(CHART_REGISTRY )
308
- @yq w -i ./charts/$* /doc.yaml repository.url --tag ' !!str' $(CHART_REGISTRY_URL )
309
- @if [ ! -z " $( CHART_VERSION) " ]; then \
310
- yq w -i ./charts/$* /Chart.yaml version --tag ' !!str' $(CHART_VERSION ) ; \
311
- yq w -i ./charts/$* /doc.yaml chart.version --tag ' !!str' $(CHART_VERSION ) ; \
312
- yq w -i ./charts/$* /doc.yaml release.name --tag ' !!str' $(BIN ) -$(CHART_VERSION ) ; \
313
- yq w -i ./docs/examples/backup/backupconfiguration.yaml spec.task.name --tag ' !!str' mysql-backup-$(CHART_VERSION ) ; \
314
- yq w -i ./docs/examples/restore/restoresession.yaml spec.task.name --tag ' !!str' mysql-restore-$(CHART_VERSION ) ; \
315
- fi
316
- @if [ ! -z " $( APP_VERSION) " ]; then \
317
- yq w -i ./charts/$* /Chart.yaml appVersion --tag ' !!str' $(APP_VERSION ) ; \
318
- yq w -i ./charts/$* /values.yaml image.tag --tag ' !!str' $(APP_VERSION ) ; \
319
- fi
134
+ gen :
135
+ @true
320
136
321
137
fmt : $(BUILD_DIRS )
322
138
@docker run \
@@ -446,32 +262,6 @@ unit-tests: $(BUILD_DIRS)
446
262
./hack/test.sh $(SRC_PKGS ) \
447
263
"
448
264
449
- .PHONY : ct
450
- ct : $(BUILD_DIRS )
451
- @docker run \
452
- -i \
453
- --rm \
454
- -v $$(pwd ) :/src \
455
- -w /src \
456
- --net=host \
457
- -v $(HOME ) /.kube:/.kube \
458
- -v $(HOME ) /.minikube:$(HOME ) /.minikube \
459
- -v $(HOME ) /.credentials:$(HOME ) /.credentials \
460
- -v $$(pwd ) /.go/bin/$(OS ) _$(ARCH ) :/go/bin \
461
- -v $$(pwd ) /.go/bin/$(OS ) _$(ARCH ) :/go/bin/$(OS ) _$(ARCH ) \
462
- -v $$(pwd ) /.go/cache:/.cache \
463
- --env HTTP_PROXY=$(HTTP_PROXY ) \
464
- --env HTTPS_PROXY=$(HTTPS_PROXY ) \
465
- --env KUBECONFIG=$(subst $(HOME ) ,,$(KUBECONFIG ) ) \
466
- $(CHART_TEST_IMAGE ) \
467
- /bin/sh -c " \
468
- kubectl -n kube-system create sa tiller; \
469
- kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller; \
470
- helm init --service-account tiller; \
471
- kubectl wait --for=condition=Ready pods -n kube-system --all --timeout=5m; \
472
- ct lint-and-install --all; \
473
- "
474
-
475
265
ADDTL_LINTERS := goconst,gofmt,goimports,unparam
476
266
477
267
.PHONY : lint
0 commit comments