{{ .Content }}
Kind
Group/Version
{{/* Each level is a map with the key being the directory name */}} {{/* $Site.Data.crds /$version/crds/yaml */}} {{ range $filename,$content := index $.Site.Data.crds .Section "api" "yaml" }} {{ with $content }} {{ $url := .ResourceType }} {{ $kind := .spec.names.kind }} {{ $group := .spec.group }} {{ $version := "" }} {{ $description := "" }} {{ $schemaScratch := newScratch }} {{/* Temporary variable used to prune fields from the larger spec */}} {{ $schemaWithStatus := dict }} {{/* The pruned schema to work with */}} {{ $bigName := gt (len $kind) 32 }} {{/* Long names overrun the display and cause problems. This allows for applying custom styles */}} {{/* Iterate over each version and find the "storage: true" version */}} {{ range .spec.versions }} {{ if index . "storage" }} {{ $version = .name }} {{ $schemaScratch.Set "oAPI" (index . "schema" "openAPIV3Schema" "properties") }} {{/* Pull out the top-level Kind description and delete unnecessary fields */}} {{ $description = (index . "schema" "openAPIV3Schema" "description") }} {{ $schemaScratch.DeleteInMap "oAPI" "apiVersion" }} {{ $schemaScratch.DeleteInMap "oAPI" "kind" }} {{ $schemaScratch.DeleteInMap "oAPI" "metadata" }} {{ $schemaScratch.DeleteInMap "oAPI" "description" }} {{ $schemaWithStatus = $schemaScratch.Get "oAPI" }} {{ end }} {{ end }} {{/* the crd-root-row is a top level CRD row */}}
{{/* Collapse/Expand Button and Kind name */}}
{{/* Plus/Minus Button */}} {{/* CRD name text */}}
{{/* If the CRD name is longer than 24 characters hide the other fields, regardless of viewport size */}}
{{ $group }}/{{ $version }}
{{/* The container to show/hide with information related to the CRD */}}
{{ if $bigName }}
{{$group}}/{{$version}}
{{ else }} {{ end }}
{{$group}}/{{$version}}
{{/* bigName-reset prevents the description from expanding into the x-scroll */}}
{{ $description | markdownify}}
{{/* Loop over the fields in the pruned Schema and generate their content */}} {{ range $key,$schema := $schemaWithStatus }}
{{ template "buildCRD" (dict "key" $key "schema" $schema "isFirst" true "kind" $kind "requiredFields" .required "rootKind" $kind "permalink" $.Page.Permalink) }}
{{ end }}
{{ end }} {{ end }}
{{ define "buildCRD" }} {{/* The first field (spec) has a different schema compared to the child nodes */}} {{ if .isFirst }} {{ $elemID := (printf "%s-%s" .kind .key) }} {{ $dataTypeStyle := .schema.type }} {{ $dataType := .schema.type }} {{ $description := .schema.description }} {{ $properties := .schema.properties }} {{ $required := .schema.required }} {{/* Special handling for arrays to check if it's a list of 'items' */}} {{ if eq .schema.type "array" }} {{ if .schema.items }} {{ $dataType = (printf "[ ]%s" .schema.items.type) }} {{ $dataTypeStyle = .schema.items.type }} {{ $description = .schema.items.description }} {{ $properties = .schema.items.properties }} {{ $required = .schema.items.required }} {{ else }} {{ $dataType = (printf "[ ]%s" .schema.type) }} {{ end }} {{ end }}
{{/* Plus/Minus Button */}} {{/* CRD name text */}} {{/* Anchor link icon */}} {{/* The container to show/hide with information related to the CRD */}}
{{ $description | markdownify }}
{{ template "buildCRD" (dict "schema" $properties "isFirst" false "kind" $elemID "requiredFields" $required "rootKind" .rootKind "permalink" .permalink ) }}
{{ else }} {{/* Iterate over all child CRD elements */}} {{ range $key,$contents := .schema }} {{ $bigName := gt (len $key) 24 }} {{ $dataType := $contents.type }} {{ $dataTypeStyle := $dataType }} {{ $elemID := (printf "%s-%s" $.kind $key) }} {{ $dataTypeStyle := $contents.type }} {{ $dataType := $contents.type }} {{ $description := $contents.description }} {{ $properties := $contents.properties }} {{ $required := $.requiredFields }} {{/* enum fields handle "oneOf" type data lists */}} {{ $enum := false }} {{ $enumOf := "" }} {{ $enumTypes := dict }} {{ if $contents.oneOf }} {{ $enum = true }} {{ $enumOf = "One of" }} {{ $enumTypes := $contents.oneOf }} {{ else if $contents.anyOf }} {{ $enum = true }} {{ $enumOf = "Any of" }} {{ $enumTypes := $contents }} {{ else if $contents.allOf }} {{ $enum = true }} {{ $enumOf = "All of" }} {{ $enumTypes := $contents.allOf }} {{ end }} {{ if eq $contents.type "array" }} {{ if $contents.items }} {{ $dataType = (printf "[ ]%s" $contents.items.type) }} {{ $dataTypeStyle = $contents.items.type }} {{/* Some "items" don't have nested elements. */}} {{/* For example CompositeResourceDefinitions.Spec.ClaimNames.categories */}} {{ if $contents.items.description }} {{ $description = $contents.items.description }} {{ end }} {{ if $contents.items.properties }} {{ $properties = $contents.items.properties }} {{ end }} {{ if $contents.items.required}} {{ $required = $contents.items.required }} {{ end }} {{ else }} {{ $dataType = (printf "[ ]%s" $contents.type) }} {{ end }} {{ end }}
{{/* Plus/Minus Button */}} {{/* CRD name text */}} {{/* Link icon */}} {{/* The container to show/hide with information related to the CRD */}}
{{$description | markdownify }}
{{ if $properties }}
{{ template "buildCRD" (dict "schema" $properties "requiredFields" $required "kind" $elemID "rootKind" $.rootKind "permalink" $.permalink ) }}
{{ end }}
{{ end }} {{/* range $key,$contents */}} {{ end }} {{/* if/else */}} {{ end }} {{/* define */}}