|
2 | 2 | {{ $state := .Get "state" }}
|
3 | 3 | {{ $for_k8s_version := .Get "for_k8s_version" | default (.Page.Param "version")}}
|
4 | 4 | {{ $is_valid := strings.Contains $valid_states $state }}
|
5 |
| -{{ if not $is_valid }} |
6 |
| -{{ errorf "%q is not a valid feature-state, use one of %q" $state $valid_states }} |
7 |
| -{{ else }} |
8 |
| -<div style="margin-top: 10px; margin-bottom: 10px;"> |
9 |
| - <b>{{ T "feature_state" }}</b> <code>Kubernetes {{ $for_k8s_version }} [{{ $state }}]</code> |
10 |
| -</div> |
| 5 | +{{ $feature_gate_name := .Get "feature_gate_name" }} |
| 6 | + |
| 7 | + <!-- When 'feature_gate_name' parameter is not specified, continue with the values provided. --> |
| 8 | +{{ if not $feature_gate_name }} |
| 9 | + {{ if not $is_valid }} |
| 10 | + {{ errorf "%q is not a valid feature-state, use one of %q" $state $valid_states }} |
| 11 | + {{ else }} |
| 12 | + <div class="my-2 feature-state-notice feature-{{ $state }}"> |
| 13 | + <b>{{ T "feature_state" }}</b> <code>{{T "feature_state_kubernetes_label" }} {{ $for_k8s_version }} [{{ $state }}]</code> |
| 14 | + </div> |
| 15 | + {{ end }} |
| 16 | + |
| 17 | +{{- else -}} |
| 18 | + <!-- When 'feature_gate_name' is specified, the following code block extracts the status of the feature gate from the description file. --> |
| 19 | + |
| 20 | + <!-- Set the path for feature gate description files --> |
| 21 | + {{- $featureGateDescriptionFilesPath := "/docs/reference/command-line-tools-reference/feature-gates" -}} |
| 22 | + |
| 23 | + <!-- Access the 'English' site and get the feature gate description pages --> |
| 24 | + {{- with index (where .Site.Sites "Language.Lang" "eq" "en") 0 -}} |
| 25 | + {{- with .GetPage $featureGateDescriptionFilesPath -}} |
| 26 | + |
| 27 | + <!-- Sort Feature gate pages list --> |
| 28 | + {{- $sortedFeatureGates := sort (.Resources.ByType "page") -}} |
| 29 | + {{- $featureGateFound := false -}} |
| 30 | + |
| 31 | + <!-- Iterate through feature gate files --> |
| 32 | + {{- range $featureGateFile := $sortedFeatureGates -}} |
| 33 | + {{- $featureGateNameFromFile := $featureGateFile.Params.Title -}} |
| 34 | + |
| 35 | + {{- if eq $featureGateNameFromFile $feature_gate_name -}} |
| 36 | + <!-- Extract information from the final stage of the feature gate --> |
| 37 | + {{- $currentStage := index $featureGateFile.Params.stages (sub (len $featureGateFile.Params.stages) 1) -}} |
| 38 | + {{- with $currentStage -}} |
| 39 | + |
| 40 | + <!-- Display feature state information --> |
| 41 | + <div class="my-2 feature-state-notice feature-{{ .stage }}" title="{{ printf "%s %s" (T "feature_state_feature_gate_tooltip") $feature_gate_name }}"> |
| 42 | + <b>{{ T "feature_state" }}</b> <code>{{T "feature_state_kubernetes_label" }} v{{ .fromVersion }} [{{ .stage }}]</code> |
| 43 | + </div> |
| 44 | + |
| 45 | + {{- $featureGateFound = true -}} |
| 46 | + {{- end -}} |
| 47 | + {{- end -}} |
| 48 | + {{- end -}} |
| 49 | + |
| 50 | + <!-- Check if specified feature gate is not found --> |
| 51 | + {{- if not $featureGateFound -}} |
| 52 | + {{- errorf "Invalid feature gate: '%s' is not recognized or lacks a matching description file in '%s'" $feature_gate_name (print "en" $featureGateDescriptionFilesPath) -}} |
| 53 | + {{- end -}} |
| 54 | + |
| 55 | + {{- end -}} |
| 56 | + {{- end -}} |
11 | 57 | {{ end }}
|
0 commit comments