_validation.tpl 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. {{- define "webdav.validation" -}}
  2. {{- $authTypes := (list "none" "basic") -}}
  3. {{- if not (mustHas .Values.webdavConfig.authType $authTypes) -}}
  4. {{- fail (printf "WebDAV - Expected [Auth Type] to be one of [%v], but got [%v]" (join ", " $authTypes) .Values.webdavConfig.authType) -}}
  5. {{- end -}}
  6. {{- if eq .Values.webdavConfig.authType "basic" -}}
  7. {{- if not .Values.webdavConfig.username -}}
  8. {{- fail "WebDAV - Expected [Username] to be configured when [Auth Type] is set to [Basic Auth]" -}}
  9. {{- end -}}
  10. {{- if not .Values.webdavConfig.password -}}
  11. {{- fail "WebDAV - Expected [Password] to be configured when [Auth Type] is set to [Basic Auth]" -}}
  12. {{- end -}}
  13. {{- end -}}
  14. {{- if and (not .Values.webdavNetwork.http) (not .Values.webdavNetwork.https) -}}
  15. {{- fail "WebDAV - Expected at least one protocol [HTTP, HTTPS] to be enabled" -}}
  16. {{- end -}}
  17. {{- if and .Values.webdavNetwork.https (not .Values.webdavNetwork.certificateID) -}}
  18. {{- fail "WebDAV - Expected a certificate to be configured when HTTPS is enabled" -}}
  19. {{- end -}}
  20. {{- if not .Values.webdavStorage.shares -}}
  21. {{- fail "WebDAV - Expected at least 1 [Share] to be configured" -}}
  22. {{- end -}}
  23. {{- range .Values.webdavStorage.shares -}}
  24. {{- if not (mustRegexMatch "^[a-zA-Z0-9_-]+$" .name) -}}
  25. {{- fail "WebDAV - Expected [Share] name to only consist of [Letters(a-z, A-Z), Numbers(0-9), Underscores(_), Dashes(-)]" -}}
  26. {{- end -}}
  27. {{- end -}}
  28. {{- end -}}