Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion charts/dv-pod/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,44 @@ Validate validator client type
{{- $validTypes := list "lighthouse" "lodestar" "teku" "prysm" "nimbus" -}}
{{- $currentType := .Values.validatorClient.type -}}
{{- if not (has $currentType $validTypes) -}}
{{- fail (printf "ERROR: Invalid validator client type '%s'. Valid options are: %s" $currentType (join ", " $validTypes)) -}}
{{- $errorMsg := printf "\n\nERROR: Invalid validator client type '%s'.\n\nValid options: %s" $currentType (join ", " $validTypes) -}}
{{- /* Try to find the closest match using simple heuristics */ -}}
{{- $suggestion := "" -}}
{{- $currentLower := lower $currentType -}}
{{- /* Check for common typos and confusions */ -}}
{{- $typoMap := dict "loki" "lodestar" "lodestar-" "lodestar" "lighthose" "lighthouse" "lighthouse-" "lighthouse" "tekku" "teku" "teku-" "teku" "prisim" "prysm" "prism" "prysm" "prysm-" "prysm" "nimbos" "nimbus" "nimbus-" "nimbus" -}}
{{- if hasKey $typoMap $currentLower -}}
{{- $suggestion = get $typoMap $currentLower -}}
{{- else -}}
{{- /* Check for prefix matches (at least 2 characters) */ -}}
{{- range $validType := $validTypes -}}
{{- $validLower := lower $validType -}}
{{- if and (gt (len $currentLower) 1) (hasPrefix $validLower (substr 0 2 $currentLower)) -}}
{{- $suggestion = $validType -}}
{{- end -}}
{{- if and (gt (len $currentLower) 2) (hasPrefix $validLower (substr 0 3 $currentLower)) -}}
{{- $suggestion = $validType -}}
{{- end -}}
{{- /* Check if valid type contains the input or vice versa */ -}}
{{- if and (gt (len $currentLower) 2) (contains $validLower $currentLower) -}}
{{- $suggestion = $validType -}}
{{- end -}}
{{- if and (gt (len $currentLower) 2) (contains $currentLower $validLower) -}}
{{- $suggestion = $validType -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- /* Add suggestion to error message if found */ -}}
{{- if $suggestion -}}
{{- $errorMsg = printf "%s\n\n⚠️ Did you mean '%s'?" $errorMsg $suggestion -}}
{{- end -}}
{{- /* Use suggestion if available, otherwise use lodestar as example */ -}}
{{- $exampleType := "lodestar" -}}
{{- if $suggestion -}}
{{- $exampleType = $suggestion -}}
{{- end -}}
{{- $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 -}}
{{- fail $errorMsg -}}
{{- end -}}
{{- end -}}
{{- end -}}
Expand Down