From 5cd274e430b40fe1d914a8379d13bb26c2f41940 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 2 Apr 2024 14:49:18 +0200 Subject: [PATCH 1/2] chore: ad option to generate single crds --- Makefile | 2 +- generate.sh | 106 +++++++++++++++++++++++++++++++--------------------- 2 files changed, 64 insertions(+), 44 deletions(-) diff --git a/Makefile b/Makefile index 8cb0738..9a348ac 100644 --- a/Makefile +++ b/Makefile @@ -30,4 +30,4 @@ clean: .PHONY: generate generate: @mkdir -p $(DIST) - @./generate.sh + @./generate.sh $(handler) diff --git a/generate.sh b/generate.sh index cf3e9cb..8e0ad9c 100755 --- a/generate.sh +++ b/generate.sh @@ -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 } -default_openapi_handler() { - printf "Processing %s ...\n" $API +exec_openapi() { + printf "Processing %s ...\n" "$API" prepare ( cd "$WORKDIR" @@ -40,6 +40,11 @@ default_openapi_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 prepare ( @@ -60,6 +65,10 @@ calico_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 mkdir -p "${WORKDIR}" curl -SsfL "${SOURCE}" | tar xz -C "${WORKDIR}" @@ -82,6 +91,11 @@ flux_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 prepare ( @@ -93,50 +107,56 @@ metallb_handler() { generate_all "$TARGET_DIR" } -## Calico -API=projectcalico.org -NAME=calico -WORKDIR="${TMP_CRD_DIR}/calico" -SOURCE="https://raw.githubusercontent.com/projectcalico/calico/${CALICO_VERSION}/manifests/calico.yaml" -calico_handler +cnpg_handler() { + API=postgresql.cnpg.io + NAME=cnpg + WORKDIR="${TMP_CRD_DIR}/$NAME" + SOURCE="https://github.com/cloudnative-pg/cloudnative-pg/releases/download/${CNPG_VERSION}/cnpg-${CNPG_VERSION##v}.yaml" -## 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 + exec_openapi +} -## 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 +certmanager_handler() { + API=cert-manager.io + NAME=cert-manager + WORKDIR="${TMP_CRD_DIR}/$NAME" + SOURCE="https://github.com/cert-manager/cert-manager/releases/download/${CERTMANAGER_VERSION}/cert-manager.crds.yaml" -## Cloudnative-PG -API=postgresql.cnpg.io -NAME=cnpg -WORKDIR="${TMP_CRD_DIR}/$NAME" -SOURCE="https://github.com/cloudnative-pg/cloudnative-pg/releases/download/${CNPG_VERSION}/cnpg-${CNPG_VERSION##v}.yaml" -default_openapi_handler + exec_openapi +} -## Cert-Manager -API=cert-manager.io -NAME=cert-manager -WORKDIR="${TMP_CRD_DIR}/$NAME" -SOURCE="https://github.com/cert-manager/cert-manager/releases/download/${CERTMANAGER_VERSION}/cert-manager.crds.yaml" -default_openapi_handler +minio_handler() { + API=minio.min.io + NAME=minio + WORKDIR="${TMP_CRD_DIR}/$NAME" + SOURCE="https://raw.githubusercontent.com/minio/operator/${MINIO_VERSION}/resources/base/crds/minio.min.io_tenants.yaml" -## Minio -API=minio.min.io -NAME=minio -WORKDIR="${TMP_CRD_DIR}/$NAME" -SOURCE="https://raw.githubusercontent.com/minio/operator/${MINIO_VERSION}/resources/base/crds/minio.min.io_tenants.yaml" -default_openapi_handler + exec_openapi +} -## K8up -API=k8up.io -NAME=k8up -WORKDIR="${TMP_CRD_DIR}/$NAME" -SOURCE="https://github.com/k8up-io/k8up/releases/download/k8up-${K8UP_VERSION}/k8up-crd.yaml" -default_openapi_handler +k8up_handler() { + API=k8up.io + NAME=k8up + WORKDIR="${TMP_CRD_DIR}/$NAME" + SOURCE="https://github.com/k8up-io/k8up/releases/download/k8up-${K8UP_VERSION}/k8up-crd.yaml" + + exec_openapi +} + +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 -- 2.45.2 From bdae11838670ed6685e14404198af098a4a86a64 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 2 Apr 2024 14:53:12 +0200 Subject: [PATCH 2/2] pass api url as arg --- generate.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/generate.sh b/generate.sh index 8e0ad9c..592f508 100755 --- a/generate.sh +++ b/generate.sh @@ -29,7 +29,7 @@ generate_all() { } exec_openapi() { - printf "Processing %s ...\n" "$API" + printf "Processing %s ...\n" "$1" prepare ( cd "$WORKDIR" @@ -113,7 +113,7 @@ cnpg_handler() { WORKDIR="${TMP_CRD_DIR}/$NAME" SOURCE="https://github.com/cloudnative-pg/cloudnative-pg/releases/download/${CNPG_VERSION}/cnpg-${CNPG_VERSION##v}.yaml" - exec_openapi + exec_openapi $API } certmanager_handler() { @@ -122,7 +122,7 @@ certmanager_handler() { WORKDIR="${TMP_CRD_DIR}/$NAME" SOURCE="https://github.com/cert-manager/cert-manager/releases/download/${CERTMANAGER_VERSION}/cert-manager.crds.yaml" - exec_openapi + exec_openapi $API } minio_handler() { @@ -131,7 +131,7 @@ minio_handler() { WORKDIR="${TMP_CRD_DIR}/$NAME" SOURCE="https://raw.githubusercontent.com/minio/operator/${MINIO_VERSION}/resources/base/crds/minio.min.io_tenants.yaml" - exec_openapi + exec_openapi $API } k8up_handler() { @@ -140,7 +140,7 @@ k8up_handler() { WORKDIR="${TMP_CRD_DIR}/$NAME" SOURCE="https://github.com/k8up-io/k8up/releases/download/k8up-${K8UP_VERSION}/k8up-crd.yaml" - exec_openapi + exec_openapi $API } handlers=( -- 2.45.2