Skip to content

Instantly share code, notes, and snippets.

@germainlefebvre4
Last active April 12, 2024 09:46
Show Gist options
  • Save germainlefebvre4/36180af06e320b1febdf4061171b492b to your computer and use it in GitHub Desktop.
Save germainlefebvre4/36180af06e320b1febdf4061171b492b to your computer and use it in GitHub Desktop.
A script to render a digest HTML page to read Kubernetes CRDs
#!/bin/bash
# Prerequisites:
# - yq: https://github.com/mikefarah/yq
# - yaml2json: https://github.com/bronze1man/yaml2json
# - generate-schema-doc: https://github.com/coveooss/json-schema-for-humans
FILE=$1
if [ ! -d html ] ; then
mkdir html
fi
cat << EOF > render.yaml
\$schema: "https://json-schema.org/draft/2020-12/schema"
type: "object"
description: ""
additionalProperties": false
EOF
yq -r '.spec.versions[0].schema.openAPIV3Schema' ${FILE} >> render.yaml
yaml2json < render.yaml > render.json
generate-schema-doc --config template_name=js --config with_footer=false --config link_to_reused_ref=true render.json html/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment