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