{{/* $.Site.Data is from the hugo config file module.mounts.target. */}}
{{/* Hugo requires YAML to be in the 'data' location for processing */}}
{{/* https://gohugo.io/methods/site/data/ */}}
{{ $crdFiles := index $.Site.Data.crds .Section "api" "crds" }}
{{/* Iterate over each CRD file */}}
{{ range $fileName, $crdContent := $crdFiles }}
{{/* The path to download the CRD files. Relative to the _index.md file using "product: crds" */}}
{{ $downloadPath := (printf "crds/%s.yaml" $fileName) }}
{{ $group := $crdContent.spec.group }}
{{ $kind := $crdContent.spec.names.kind }}
{{/* bigName is the kind length limit to change CSS styles when it needs to be truncated */}}
{{ $bigName := partial "apiBuilder/checkBigName" $kind }}
{{/* Find the active version. We prefer the "storage: true" value but use "served: true" as a backup */}}
{{ $versionAndSchema := partial "apiBuilder/getVersionAndSchema" $crdContent.spec }}
{{ $schema := $versionAndSchema.schema.openAPIV3Schema }}
{{ $version := $versionAndSchema.version }}
{{ $description := $schema.description }}
{{/* The div containing the entire CRD information including the Expand All/Collapse All row */}}
{{/* generate the GKV line to expand/collapse the CRD data */}}
{{ partial "apiBuilder/printGKVExpander" (dict "group" $group "version" $version "kind" $kind) }}
{{/* The container to show/hide with information related to the CRD */}}
{{/* Generate the "Download YAML" link */}}
{{ partial "apiBuilder/downloadLink" (dict "group" $group "version" $version "kind" $kind "downloadPath" $downloadPath) }}
{{/* bigName-reset prevents the description from expanding into the x-scroll */}}
{{ $description | markdownify}}
{{/* Loop over each key inside the schema */}}
{{ range $key, $contents := $schema.properties }}
{{/* Skip irrelevant keys at the top level */}}
{{ if not (in (slice "apiVersion" "description" "kind" "metadata") $key) }}
{{ partial "apiBuilder/processSpec" (dict "key" $key "contents" $contents "page" . "kind" $kind) }}
{{ end }}
{{ end }}
{{/* Generate the "Return to top" link */}}
{{ partialCached "apiBuilder/backToTopButton" . }}