2018-05-05 16:00:51 +00:00
{{ $valid_states := "alpha, beta, deprecated, stable" }}
{{ $state := .Get "state" }}
2024-09-17 22:17:02 +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" }}
{{ if not $feature_gate_name }}
{{ if not $is_valid }}
{{ errorf "%q is not a valid feature-state, use one of %q" $state $valid_states }}
2024-10-31 21:07:27 +00:00
{{- else -}}
{{- /* Display feature state notice */ -}}
2024-09-17 22:17:02 +00:00
< div class = "feature-state-notice feature-{{ $state }}" >
2024-10-31 21:07:27 +00:00
< span class = "feature-state-name" > {{ T "feature_state" }}< / span >
2024-09-17 22:17:02 +00:00
< code > {{ T "feature_state_kubernetes_label" }} {{ $for_k8s_version }} [{{ $state }}]< / code >
< / div >
2024-02-06 00:28:22 +00:00
{{ end }}
2024-09-17 22:17:02 +00:00
{{ else }}
<!-- When 'feature_gate_name' is specified, extract status of the feature gate -->
2024-10-31 21:07:27 +00:00
2024-02-06 00:28:22 +00:00
{{- $featureGateDescriptionFilesPath := "/docs/reference/command-line-tools-reference/feature-gates" -}}
2024-10-31 21:07:27 +00:00
2024-02-06 00:28:22 +00:00
{{- with index (where .Site.Sites "Language.Lang" "eq" "en") 0 -}}
{{- with .GetPage $featureGateDescriptionFilesPath -}}
{{- $sortedFeatureGates := sort (.Resources.ByType "page") -}}
{{- $featureGateFound := false -}}
{{- 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 -}}
{{- $currentStage := index $featureGateFile.Params.stages (sub (len $featureGateFile.Params.stages) 1) -}}
2024-04-22 23:42:14 +00:00
{{- with $currentStage -}}
2024-09-17 22:17:02 +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 >
2024-10-18 17:41:58 +00:00
< code > {{ T "feature_state_kubernetes_label" }} v{{ .fromVersion }} [{{ .stage }}]< / code > {{ T "feature_gate_enabled" (dict "enabled" .defaultValue) }}
2024-09-17 22:17:02 +00:00
< / 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 -}}
{{- if not $featureGateFound -}}
2024-09-17 22:17:02 +00:00
{{- errorf "Invalid feature gate: '%s' is not recognized or lacks a matching description file in '%s'" $feature_gate_name (print "en" $featureGateDescriptionFilesPath) -}}
2024-02-06 00:28:22 +00:00
{{- end -}}
{{- end -}}
{{- end -}}
2022-02-18 22:30:23 +00:00
{{ end }}