2018-05-05 16:00:51 +00:00
{{ $valid_states := "alpha, beta, deprecated, stable" }}
{{ $state := .Get "state" }}
2020-05-11 16:01:05 +00:00
{{ $for_k8s_version := .Get "for_k8s_version" | default (.Page.Param "version")}}
2018-05-05 16:00:51 +00:00
{{ $is_valid := strings.Contains $valid_states $state }}
2024-02-06 00:28:22 +00:00
{{ $feature_gate_name := .Get "feature_gate_name" }}
<!-- When 'feature_gate_name' parameter is not specified, continue with the values provided. -->
{{ if not $feature_gate_name }}
{{ if not $is_valid }}
{{ errorf "%q is not a valid feature-state, use one of %q" $state $valid_states }}
{{ else }}
2024-04-22 23:42:14 +00:00
< div class = "feature-state-notice feature-{{ $state }}" >
< span class = "feature-state-name" > {{ T "feature_state" }}< / span > < code > {{T "feature_state_kubernetes_label" }} {{ $for_k8s_version }} [{{ $state }}]< / code >
2024-02-19 00:47:09 +00:00
< / div >
2024-02-06 00:28:22 +00:00
{{ end }}
{{- else -}}
<!-- When 'feature_gate_name' is specified, the following code block extracts the status of the feature gate from the description file. -->
<!-- Set the path for feature gate description files -->
{{- $featureGateDescriptionFilesPath := "/docs/reference/command-line-tools-reference/feature-gates" -}}
<!-- Access the 'English' site and get the feature gate description pages -->
{{- with index (where .Site.Sites "Language.Lang" "eq" "en") 0 -}}
{{- with .GetPage $featureGateDescriptionFilesPath -}}
<!-- Sort Feature gate pages list -->
{{- $sortedFeatureGates := sort (.Resources.ByType "page") -}}
{{- $featureGateFound := false -}}
<!-- Iterate through feature gate files -->
{{- range $featureGateFile := $sortedFeatureGates -}}
{{- $featureGateNameFromFile := $featureGateFile.Params.Title -}}
2024-04-22 23:42:14 +00:00
2024-02-06 00:28:22 +00:00
{{- if eq $featureGateNameFromFile $feature_gate_name -}}
<!-- Extract information from the final stage of the feature gate -->
{{- $currentStage := index $featureGateFile.Params.stages (sub (len $featureGateFile.Params.stages) 1) -}}
2024-04-22 23:42:14 +00:00
{{- with $currentStage -}}
2024-02-06 00:28:22 +00:00
<!-- Display feature state information -->
2024-04-22 23:42:14 +00:00
< div class = "feature-state-notice feature-{{ .stage }}" title = "{{ printf " % s % s " ( T " feature_state_feature_gate_tooltip " ) $ feature_gate_name } } " >
< span class = "feature-state-name" > {{ T "feature_state" }}< / span > < code > {{T "feature_state_kubernetes_label" }} v{{ .fromVersion }} [{{ .stage }}]< / code >
< / div >
2024-02-06 00:28:22 +00:00
2024-04-22 23:42:14 +00:00
{{- $featureGateFound = true -}}
{{- end -}}
2024-02-06 00:28:22 +00:00
{{- end -}}
{{- end -}}
<!-- Check if specified feature gate is not found -->
{{- if not $featureGateFound -}}
{{- errorf "Invalid feature gate: '%s' is not recognized or lacks a matching description file in '%s'" $feature_gate_name (print "en" $featureGateDescriptionFilesPath) -}}
{{- end -}}
{{- end -}}
{{- end -}}
2022-02-18 22:30:23 +00:00
{{ end }}