feat: generate multi-schema files for each API resource (#54)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #54 Co-authored-by: Robert Kaussow <mail@thegeeklab.de> Co-committed-by: Robert Kaussow <mail@thegeeklab.de>
This commit is contained in:
parent
b453296209
commit
f9dfe67eeb
16
generate.sh
16
generate.sh
@ -2,6 +2,16 @@
|
|||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
shopt -s globstar
|
shopt -s globstar
|
||||||
|
|
||||||
|
generate_all() {
|
||||||
|
export SOURCE=$1
|
||||||
|
|
||||||
|
export TYPE=anyOf
|
||||||
|
gomplate -d source=env:SOURCE -d type=env:TYPE -o "$SOURCE/all-$TYPE.json" -f templates/all.json.tmpl
|
||||||
|
|
||||||
|
export TYPE=oneOf
|
||||||
|
gomplate -d source=env:SOURCE -d type=env:TYPE -o "$SOURCE/all-$TYPE.json" -f templates/all.json.tmpl
|
||||||
|
}
|
||||||
|
|
||||||
default_openapi_handler() {
|
default_openapi_handler() {
|
||||||
printf "Processing %s ...\n" $API
|
printf "Processing %s ...\n" $API
|
||||||
mkdir -p "${WORKDIR}"
|
mkdir -p "${WORKDIR}"
|
||||||
@ -19,6 +29,8 @@ default_openapi_handler() {
|
|||||||
|
|
||||||
mv "$FILE" "$TARGET_DIR/$FILENAME"
|
mv "$FILE" "$TARGET_DIR/$FILENAME"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
generate_all "$TARGET_DIR"
|
||||||
}
|
}
|
||||||
|
|
||||||
## Calico
|
## Calico
|
||||||
@ -43,6 +55,8 @@ for FILE in "${WORKDIR}"/*.json; do
|
|||||||
mv "$FILE" "$TARGET_DIR/${FILENAME//_v1/_v3}"
|
mv "$FILE" "$TARGET_DIR/${FILENAME//_v1/_v3}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
generate_all "$TARGET_DIR"
|
||||||
|
|
||||||
## Flux2
|
## Flux2
|
||||||
API=toolkit.fluxcd.io
|
API=toolkit.fluxcd.io
|
||||||
WORKDIR="${TMP_CRD_DIR}/flux"
|
WORKDIR="${TMP_CRD_DIR}/flux"
|
||||||
@ -64,6 +78,8 @@ for FILE in "${WORKDIR}"/*.json; do
|
|||||||
|
|
||||||
mkdir -p "$TARGET_DIR"
|
mkdir -p "$TARGET_DIR"
|
||||||
mv "$FILE" "$TARGET_NAME"
|
mv "$FILE" "$TARGET_NAME"
|
||||||
|
|
||||||
|
generate_all "$TARGET_DIR"
|
||||||
done
|
done
|
||||||
|
|
||||||
## Cloudnative-PG
|
## Cloudnative-PG
|
||||||
|
13
templates/all.json.tmpl
Normal file
13
templates/all.json.tmpl
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"{{ ds "type" }}": [
|
||||||
|
{{- $path := ds "source" }}
|
||||||
|
{{- $filelist := file.ReadDir $path }}
|
||||||
|
{{- $length := len $filelist}}
|
||||||
|
{{- range $i, $item := $filelist }}
|
||||||
|
{{- if $i }},{{ end }}
|
||||||
|
{
|
||||||
|
"$ref": "https://gitea.rknet.org/infra/crds-catalog/raw/branch/catalog/{{ $path | path.Base }}/{{ $item }}"
|
||||||
|
}
|
||||||
|
{{- end }}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user