-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a validation to check if there is any yaml errors after merging f…
…iles
- Loading branch information
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{{/* Validates any object that it does not contain helm errors */}} | ||
{{/* This usually can happen after merging values from an include that did not render correcly */}} | ||
{{/* Any object will be passed to "toYaml" */}} | ||
{{/* Call this template: | ||
{{ include "ix.v1.common.values.validate" . }} | ||
*/}} | ||
{{- define "ix.v1.common.values.validate" -}} | ||
{{- $allValues := (toYaml .) -}} | ||
|
||
{{- if contains "error converting YAML to JSON" $allValues -}} | ||
{{/* Print values to show values with the error included. */}} | ||
{{/* Ideally we would want to extract the error only, but because it usually contains ":", | ||
It gets parsed as dict and it cant regex matched it afterwards */}} | ||
|
||
{{- fail (printf "Chart - Values contain an error that may be a result of merging. Values containing the error: \n\n %v \n\n See error above values." $allValues) -}} | ||
{{- end -}} | ||
|
||
{{- end -}} |