_validation.tpl 803 B

12345678910111213141516171819202122232425
  1. {{/* Secret Validation */}}
  2. {{/* Call this template:
  3. {{ include "ix.v1.common.lib.secret.validation" (dict "objectData" $objectData) -}}
  4. objectData:
  5. labels: The labels of the secret.
  6. annotations: The annotations of the secret.
  7. data: The data of the secret.
  8. */}}
  9. {{- define "ix.v1.common.lib.secret.validation" -}}
  10. {{- $objectData := .objectData -}}
  11. {{- if not $objectData.data -}}
  12. {{- fail "Secret - Expected non-empty <data>" -}}
  13. {{- end -}}
  14. {{- if not (kindIs "map" $objectData.data) -}}
  15. {{- fail (printf "Secret - Expected <data> to be a dictionary, but got [%v]" (kindOf $objectData.data)) -}}
  16. {{- end -}}
  17. {{- if and (hasKey $objectData "type") (not $objectData.type) -}}
  18. {{- fail (printf "Secret - Found <type> key, but it's empty") -}}
  19. {{- end -}}
  20. {{- end -}}