Skip to content

Commit

Permalink
[cherry-pick] Speed up schema generation process (#250) (#252)
Browse files Browse the repository at this point in the history
/cherry-pick

Signed-off-by: Tamal Saha <tamal@appscode.com>

Co-authored-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
1gtm and tamalsaha authored Dec 25, 2020
1 parent 1393938 commit e96a04e
Show file tree
Hide file tree
Showing 1,669 changed files with 22,566 additions and 297,790 deletions.
35 changes: 23 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ RESTIC_VER := 0.11.0
### These variables should not need tweaking.
###

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

DOCKER_PLATFORMS := linux/amd64
BIN_PLATFORMS := $(DOCKER_PLATFORMS)
Expand Down Expand Up @@ -202,20 +202,20 @@ gen-crds:
controller-gen \
$(CRD_OPTIONS) \
paths="./apis/..." \
output:crd:artifacts:config=api/crds
output:crd:artifacts:config=crds

crds_to_patch := installer.stash.appscode.com_stashmysqls.yaml

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

.PHONY: label-crds
label-crds: $(BUILD_DIRS)
@for f in api/crds/*.yaml; do \
@for f in crds/*.yaml; do \
echo "applying app=stash label to $$f"; \
kubectl label --overwrite -f $$f --local=true -o yaml app=stash > bin/crd.yaml; \
mv bin/crd.yaml $$f; \
Expand Down Expand Up @@ -248,17 +248,28 @@ gen-bindata:
--rm \
-u $$(id -u):$$(id -g) \
-v $$(pwd):/src \
-w /src/api/crds \
-w /src/crds \
-v /tmp:/.cache \
--env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \
$(BUILD_IMAGE) \
go-bindata -ignore=\\.go -ignore=\\.DS_Store -mode=0644 -modtime=1573722179 -o bindata.go -pkg crds ./...

.PHONY: gen-values-schema
gen-values-schema:
@yq r api/crds/installer.stash.appscode.com_stashmysqls.v1.yaml spec.versions[0].schema.openAPIV3Schema.properties.spec > /tmp/stash-mysql-values.openapiv3_schema.yaml
@yq d /tmp/stash-mysql-values.openapiv3_schema.yaml description > charts/stash-mysql/values.openapiv3_schema.yaml
gen-values-schema: $(BUILD_DIRS)
@for dir in charts/*/; do \
dir=$${dir%*/}; \
dir=$${dir##*/}; \
crd=$$(echo $$dir | tr -d '-'); \
yq r crds/installer.stash.appscode.com_$${crd}s.yaml spec.versions[0].schema.openAPIV3Schema.properties.spec > bin/values.openapiv3_schema.yaml; \
yq d bin/values.openapiv3_schema.yaml description > charts/$${dir}/values.openapiv3_schema.yaml; \
rm -rf bin/values.openapiv3_schema.yaml; \
done

.PHONY: gen-readme
gen-readme:
@jq -n -c --arg v "$(CHART_VERSION)" '{"version":$$v}' > /tmp/data.json
@render-gotpl --template=hack/templates/readme.txt --data=/tmp/data.json > README.md

.PHONY: gen-chart-doc
gen-chart-doc: gen-chart-doc-stash-mysql
Expand All @@ -276,10 +287,10 @@ gen-chart-doc-%:
chart-doc-gen -d ./charts/$*/doc.yaml -v ./charts/$*/values.yaml > ./charts/$*/README.md

.PHONY: manifests
manifests: gen-crds patch-crds label-crds gen-bindata gen-values-schema gen-chart-doc
manifests: gen-crds gen-values-schema gen-chart-doc

.PHONY: gen
gen: clientset gen-crd-protos manifests openapi
gen: clientset manifests

CHART_REGISTRY ?= appscode
CHART_REGISTRY_URL ?= https://charts.appscode.com/stable/
Expand Down
267 changes: 0 additions & 267 deletions api/crds/bindata.go

This file was deleted.

46 changes: 0 additions & 46 deletions api/crds/lib.go

This file was deleted.

Loading

0 comments on commit e96a04e

Please sign in to comment.