chore: ad option to generate single crds (#81)
All checks were successful
ci/woodpecker/push/build-package Pipeline was successful
ci/woodpecker/push/notify Pipeline was successful

Reviewed-on: #81
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
Co-committed-by: Robert Kaussow <mail@thegeeklab.de>
This commit is contained in:
Robert Kaussow 2024-04-02 14:57:12 +02:00 committed by Robert Kaussow
parent 66fc348203
commit cb5f0f53ad
2 changed files with 64 additions and 44 deletions

View File

@ -30,4 +30,4 @@ clean:
.PHONY: generate .PHONY: generate
generate: generate:
@mkdir -p $(DIST) @mkdir -p $(DIST)
@./generate.sh @./generate.sh $(handler)

View File

@ -28,8 +28,8 @@ generate_all() {
gomplate -d source=env:SOURCE -d type=env:TYPE -o "$SOURCE/all-$TYPE.json" -f templates/all.json.tmpl gomplate -d source=env:SOURCE -d type=env:TYPE -o "$SOURCE/all-$TYPE.json" -f templates/all.json.tmpl
} }
default_openapi_handler() { exec_openapi() {
printf "Processing %s ...\n" $API printf "Processing %s ...\n" "$1"
prepare prepare
( (
cd "$WORKDIR" cd "$WORKDIR"
@ -40,6 +40,11 @@ default_openapi_handler() {
} }
calico_handler() { calico_handler() {
API=projectcalico.org
NAME=calico
WORKDIR="${TMP_CRD_DIR}/calico"
SOURCE="https://raw.githubusercontent.com/projectcalico/calico/${CALICO_VERSION}/manifests/calico.yaml"
printf "Processing %s ...\n" $API printf "Processing %s ...\n" $API
prepare prepare
( (
@ -60,6 +65,10 @@ calico_handler() {
} }
flux_handler() { flux_handler() {
API=toolkit.fluxcd.io
WORKDIR="${TMP_CRD_DIR}/flux"
SOURCE="https://github.com/fluxcd/flux2/releases/download/${FLUXCD_VERSION}/crd-schemas.tar.gz"
printf "Processing %s ...\n" $API printf "Processing %s ...\n" $API
mkdir -p "${WORKDIR}" mkdir -p "${WORKDIR}"
curl -SsfL "${SOURCE}" | tar xz -C "${WORKDIR}" curl -SsfL "${SOURCE}" | tar xz -C "${WORKDIR}"
@ -82,6 +91,11 @@ flux_handler() {
} }
metallb_handler() { metallb_handler() {
API=metallb.io
NAME=metallb
WORKDIR="${TMP_CRD_DIR}/$NAME"
SOURCE="https://raw.githubusercontent.com/metallb/metallb/${METALLB_VERSION}/charts/metallb/charts/crds/templates/crds.yaml"
printf "Processing %s ...\n" $API printf "Processing %s ...\n" $API
prepare prepare
( (
@ -93,50 +107,56 @@ metallb_handler() {
generate_all "$TARGET_DIR" generate_all "$TARGET_DIR"
} }
## Calico cnpg_handler() {
API=projectcalico.org
NAME=calico
WORKDIR="${TMP_CRD_DIR}/calico"
SOURCE="https://raw.githubusercontent.com/projectcalico/calico/${CALICO_VERSION}/manifests/calico.yaml"
calico_handler
## Flux2
API=toolkit.fluxcd.io
WORKDIR="${TMP_CRD_DIR}/flux"
SOURCE="https://github.com/fluxcd/flux2/releases/download/${FLUXCD_VERSION}/crd-schemas.tar.gz"
flux_handler
## Metallb
API=metallb.io
NAME=metallb
WORKDIR="${TMP_CRD_DIR}/$NAME"
SOURCE="https://raw.githubusercontent.com/metallb/metallb/${METALLB_VERSION}/charts/metallb/charts/crds/templates/crds.yaml"
metallb_handler
## Cloudnative-PG
API=postgresql.cnpg.io API=postgresql.cnpg.io
NAME=cnpg NAME=cnpg
WORKDIR="${TMP_CRD_DIR}/$NAME" WORKDIR="${TMP_CRD_DIR}/$NAME"
SOURCE="https://github.com/cloudnative-pg/cloudnative-pg/releases/download/${CNPG_VERSION}/cnpg-${CNPG_VERSION##v}.yaml" SOURCE="https://github.com/cloudnative-pg/cloudnative-pg/releases/download/${CNPG_VERSION}/cnpg-${CNPG_VERSION##v}.yaml"
default_openapi_handler
## Cert-Manager exec_openapi $API
}
certmanager_handler() {
API=cert-manager.io API=cert-manager.io
NAME=cert-manager NAME=cert-manager
WORKDIR="${TMP_CRD_DIR}/$NAME" WORKDIR="${TMP_CRD_DIR}/$NAME"
SOURCE="https://github.com/cert-manager/cert-manager/releases/download/${CERTMANAGER_VERSION}/cert-manager.crds.yaml" SOURCE="https://github.com/cert-manager/cert-manager/releases/download/${CERTMANAGER_VERSION}/cert-manager.crds.yaml"
default_openapi_handler
## Minio exec_openapi $API
}
minio_handler() {
API=minio.min.io API=minio.min.io
NAME=minio NAME=minio
WORKDIR="${TMP_CRD_DIR}/$NAME" WORKDIR="${TMP_CRD_DIR}/$NAME"
SOURCE="https://raw.githubusercontent.com/minio/operator/${MINIO_VERSION}/resources/base/crds/minio.min.io_tenants.yaml" SOURCE="https://raw.githubusercontent.com/minio/operator/${MINIO_VERSION}/resources/base/crds/minio.min.io_tenants.yaml"
default_openapi_handler
## K8up exec_openapi $API
}
k8up_handler() {
API=k8up.io API=k8up.io
NAME=k8up NAME=k8up
WORKDIR="${TMP_CRD_DIR}/$NAME" WORKDIR="${TMP_CRD_DIR}/$NAME"
SOURCE="https://github.com/k8up-io/k8up/releases/download/k8up-${K8UP_VERSION}/k8up-crd.yaml" SOURCE="https://github.com/k8up-io/k8up/releases/download/k8up-${K8UP_VERSION}/k8up-crd.yaml"
default_openapi_handler
exec_openapi $API
}
handlers=(
calico_handler
flux_handler
metallb_handler
cnpg_handler
certmanager_handler
minio_handler
k8up_handler
)
if [ $# -eq 0 ]; then
for handler in "${handlers[@]}"; do
"$handler"
done
else
"$1"_handler
fi