Skip to content

Commit a60735d

Browse files
1gtmtamalsaha
andauthored
[cherry-pick] Speed up schema generation process (#501) (#509)
/cherry-pick Signed-off-by: Tamal Saha <tamal@appscode.com> Co-authored-by: Tamal Saha <tamal@appscode.com>
1 parent e384f2f commit a60735d

File tree

1,665 files changed

+22531
-297857
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,665 files changed

+22531
-297857
lines changed

Makefile

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ BIN := stash-postgres
2020
COMPRESS ?= no
2121

2222
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
23-
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false,crdVersions={v1beta1,v1}"
23+
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false,crdVersions={v1}"
2424
# https://github.com/appscodelabs/gengo-builder
2525
CODE_GENERATOR_IMAGE ?= appscode/gengo:release-1.18
2626
API_GROUPS ?= installer:v1alpha1
@@ -54,8 +54,8 @@ RESTIC_VER := 0.11.0
5454
### These variables should not need tweaking.
5555
###
5656

57-
SRC_PKGS := api apis cmd pkg
58-
SRC_DIRS := $(SRC_PKGS) hack/gencrd # directories which hold app source (not vendored)
57+
SRC_PKGS := apis cmd pkg
58+
SRC_DIRS := $(SRC_PKGS) # directories which hold app source (not vendored)
5959

6060
DOCKER_PLATFORMS := linux/amd64 linux/arm64
6161
BIN_PLATFORMS := $(DOCKER_PLATFORMS)
@@ -202,20 +202,20 @@ gen-crds:
202202
controller-gen \
203203
$(CRD_OPTIONS) \
204204
paths="./apis/..." \
205-
output:crd:artifacts:config=api/crds
205+
output:crd:artifacts:config=crds
206206

207207
crds_to_patch := installer.stash.appscode.com_stashpostgreses.yaml
208208

209209
.PHONY: patch-crds
210210
patch-crds: $(addprefix patch-crd-, $(crds_to_patch))
211211
patch-crd-%: $(BUILD_DIRS)
212212
@echo "patching $*"
213-
@kubectl patch -f api/crds/$* -p "$$(cat hack/crd-patch.json)" --type=json --local=true -o yaml > bin/$*
214-
@mv bin/$* api/crds/$*
213+
@kubectl patch -f crds/$* -p "$$(cat hack/crd-patch.json)" --type=json --local=true -o yaml > bin/$*
214+
@mv bin/$* crds/$*
215215

216216
.PHONY: label-crds
217217
label-crds: $(BUILD_DIRS)
218-
@for f in api/crds/*.yaml; do \
218+
@for f in crds/*.yaml; do \
219219
echo "applying app=stash label to $$f"; \
220220
kubectl label --overwrite -f $$f --local=true -o yaml app=stash > bin/crd.yaml; \
221221
mv bin/crd.yaml $$f; \
@@ -248,17 +248,23 @@ gen-bindata:
248248
--rm \
249249
-u $$(id -u):$$(id -g) \
250250
-v $$(pwd):/src \
251-
-w /src/api/crds \
251+
-w /src/crds \
252252
-v /tmp:/.cache \
253253
--env HTTP_PROXY=$(HTTP_PROXY) \
254254
--env HTTPS_PROXY=$(HTTPS_PROXY) \
255255
$(BUILD_IMAGE) \
256256
go-bindata -ignore=\\.go -ignore=\\.DS_Store -mode=0644 -modtime=1573722179 -o bindata.go -pkg crds ./...
257257

258258
.PHONY: gen-values-schema
259-
gen-values-schema:
260-
@yq r api/crds/installer.stash.appscode.com_stashpostgreses.v1.yaml spec.versions[0].schema.openAPIV3Schema.properties.spec > /tmp/stash-postgres-values.openapiv3_schema.yaml
261-
@yq d /tmp/stash-postgres-values.openapiv3_schema.yaml description > charts/stash-postgres/values.openapiv3_schema.yaml
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
262268

263269
.PHONY: gen-chart-doc
264270
gen-chart-doc: gen-chart-doc-stash-postgres
@@ -276,10 +282,10 @@ gen-chart-doc-%:
276282
chart-doc-gen -d ./charts/$*/doc.yaml -v ./charts/$*/values.yaml > ./charts/$*/README.md
277283

278284
.PHONY: manifests
279-
manifests: gen-crds patch-crds label-crds gen-bindata gen-values-schema gen-chart-doc
285+
manifests: gen-crds gen-values-schema gen-chart-doc
280286

281287
.PHONY: gen
282-
gen: clientset gen-crd-protos manifests openapi
288+
gen: clientset manifests
283289

284290
CHART_REGISTRY ?= appscode
285291
CHART_REGISTRY_URL ?= https://charts.appscode.com/stable/

api/crds/bindata.go

Lines changed: 0 additions & 267 deletions
This file was deleted.

0 commit comments

Comments
 (0)