Skip to content

Commit

Permalink
[cherry-pick] Speed up schema generation process (#507) (#514)
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 2d738a4 commit c37730e
Show file tree
Hide file tree
Showing 1,667 changed files with 22,578 additions and 297,805 deletions.
37 changes: 24 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BIN := stash-elasticsearch
COMPRESS ?= no

# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false,crdVersions={v1beta1,v1}"
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false,crdVersions={v1}"
# https://github.com/appscodelabs/gengo-builder
CODE_GENERATOR_IMAGE ?= appscode/gengo:release-1.18
API_GROUPS ?= installer:v1alpha1
Expand Down 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_stashelasticsearches.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_stashelasticsearches.v1.yaml spec.versions[0].schema.openAPIV3Schema.properties.spec > /tmp/stash-elasticsearch-values.openapiv3_schema.yaml
@yq d /tmp/stash-elasticsearch-values.openapiv3_schema.yaml description > charts/stash-elasticsearch/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-elasticsearch
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Install Elasticsearch 7.2.0 backup or restore plugin for Stash as below.
```console
helm repo add appscode https://charts.appscode.com/stable/
helm repo update
helm install appscode/stash-elasticsearch --name=stash-elasticsearch-7.2.0 --version=7.2.0
helm install stash-elasticsearch-7.3.2 appscode/stash-elasticsearch --version=7.3.2 --namespace=kube-system
```

To install catalog for all supported Elasticsearch versions, please visit [here](https://github.com/stashed/catalog).
Expand All @@ -25,7 +25,7 @@ To install catalog for all supported Elasticsearch versions, please visit [here]
Uninstall Elasticsearch 7.2.0 backup or restore plugin for Stash as below.

```console
helm delete stash-elasticsearch-7.2.0
helm uninstall stash-elasticsearch-7.3.2 --namespace=kube-system
```

## Support
Expand Down
267 changes: 0 additions & 267 deletions api/crds/bindata.go

This file was deleted.

Loading

0 comments on commit c37730e

Please sign in to comment.