Skip to content

Commit a144ed3

Browse files
committed
Merge PR #150: Enhance validator client type validation
2 parents 47e7703 + 3b374fb commit a144ed3

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

charts/dv-pod/templates/_helpers.tpl

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,44 @@ Validate validator client type
156156
{{- $validTypes := list "lighthouse" "lodestar" "teku" "prysm" "nimbus" -}}
157157
{{- $currentType := .Values.validatorClient.type -}}
158158
{{- if not (has $currentType $validTypes) -}}
159-
{{- fail (printf "ERROR: Invalid validator client type '%s'. Valid options are: %s" $currentType (join ", " $validTypes)) -}}
159+
{{- $errorMsg := printf "\n\nERROR: Invalid validator client type '%s'.\n\nValid options: %s" $currentType (join ", " $validTypes) -}}
160+
{{- /* Try to find the closest match using simple heuristics */ -}}
161+
{{- $suggestion := "" -}}
162+
{{- $currentLower := lower $currentType -}}
163+
{{- /* Check for common typos and confusions */ -}}
164+
{{- $typoMap := dict "loki" "lodestar" "lodestar-" "lodestar" "lighthose" "lighthouse" "lighthouse-" "lighthouse" "tekku" "teku" "teku-" "teku" "prisim" "prysm" "prism" "prysm" "prysm-" "prysm" "nimbos" "nimbus" "nimbus-" "nimbus" -}}
165+
{{- if hasKey $typoMap $currentLower -}}
166+
{{- $suggestion = get $typoMap $currentLower -}}
167+
{{- else -}}
168+
{{- /* Check for prefix matches (at least 2 characters) */ -}}
169+
{{- range $validType := $validTypes -}}
170+
{{- $validLower := lower $validType -}}
171+
{{- if and (gt (len $currentLower) 1) (hasPrefix $validLower (substr 0 2 $currentLower)) -}}
172+
{{- $suggestion = $validType -}}
173+
{{- end -}}
174+
{{- if and (gt (len $currentLower) 2) (hasPrefix $validLower (substr 0 3 $currentLower)) -}}
175+
{{- $suggestion = $validType -}}
176+
{{- end -}}
177+
{{- /* Check if valid type contains the input or vice versa */ -}}
178+
{{- if and (gt (len $currentLower) 2) (contains $validLower $currentLower) -}}
179+
{{- $suggestion = $validType -}}
180+
{{- end -}}
181+
{{- if and (gt (len $currentLower) 2) (contains $currentLower $validLower) -}}
182+
{{- $suggestion = $validType -}}
183+
{{- end -}}
184+
{{- end -}}
185+
{{- end -}}
186+
{{- /* Add suggestion to error message if found */ -}}
187+
{{- if $suggestion -}}
188+
{{- $errorMsg = printf "%s\n\n⚠️ Did you mean '%s'?" $errorMsg $suggestion -}}
189+
{{- end -}}
190+
{{- /* Use suggestion if available, otherwise use lodestar as example */ -}}
191+
{{- $exampleType := "lodestar" -}}
192+
{{- if $suggestion -}}
193+
{{- $exampleType = $suggestion -}}
194+
{{- end -}}
195+
{{- $errorMsg = printf "%s\n\nHow to fix this:\n • Using --set flag:\n --set validatorClient.type=%s\n\n • In your values.yaml file:\n validatorClient:\n type: %s\n\n • Using custom values file:\n helm install my-dv-pod obol/dv-pod -f myvalues.yaml\n\nFor more information, see the Validator Client section in charts/dv-pod/README.md\n" $errorMsg $exampleType $exampleType -}}
196+
{{- fail $errorMsg -}}
160197
{{- end -}}
161198
{{- end -}}
162199
{{- end -}}

0 commit comments

Comments
 (0)