feat: generate multi-schema files for each API resource #54
16
generate.sh
16
generate.sh
@ -2,6 +2,16 @@
|
||||
set -eo pipefail
|
||||
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() {
|
||||
printf "Processing %s ...\n" $API
|
||||
mkdir -p "${WORKDIR}"
|
||||
@ -19,6 +29,8 @@ default_openapi_handler() {
|
||||
|
||||
mv "$FILE" "$TARGET_DIR/$FILENAME"
|
||||
done
|
||||
|
||||
generate_all "$TARGET_DIR"
|
||||
}
|
||||
|
||||
## Calico
|
||||
@ -43,6 +55,8 @@ for FILE in "${WORKDIR}"/*.json; do
|
||||
mv "$FILE" "$TARGET_DIR/${FILENAME//_v1/_v3}"
|
||||
done
|
||||
|
||||
generate_all "$TARGET_DIR"
|
||||
|
||||
## Flux2
|
||||
API=toolkit.fluxcd.io
|
||||
WORKDIR="${TMP_CRD_DIR}/flux"
|
||||
@ -64,6 +78,8 @@ for FILE in "${WORKDIR}"/*.json; do
|
||||
|
||||
mkdir -p "$TARGET_DIR"
|
||||
mv "$FILE" "$TARGET_NAME"
|
||||
|
||||
generate_all "$TARGET_DIR"
|
||||
done
|
||||
|
||||
## 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