_httpGet.tpl 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. {{/* Returns httpGet action */}}
  2. {{/* Call this template:
  3. {{ include "ix.v1.common.lib.container.actions.httpGet" (dict "rootCtx" $ "objectData" $objectData "caller" $caller) }}
  4. rootCtx: The root context of the chart.
  5. objectData: The object data to be used to render the container.
  6. */}}
  7. {{- define "ix.v1.common.lib.container.actions.httpGet" -}}
  8. {{- $rootCtx := .rootCtx -}}
  9. {{- $objectData := .objectData -}}
  10. {{- $caller := .caller -}}
  11. {{- if not $objectData.port -}}
  12. {{- fail (printf "Container - Expected non-empty <%s> <port> on [http] type" $caller) -}}
  13. {{- end -}}
  14. {{- $port := $objectData.port -}}
  15. {{- $path := "/" -}}
  16. {{- $scheme := "http" -}}
  17. {{- if kindIs "string" $port -}}
  18. {{- $port = tpl $port $rootCtx -}}
  19. {{- end -}}
  20. {{- with $objectData.path -}}
  21. {{- $path = tpl . $rootCtx -}}
  22. {{- end -}}
  23. {{- if not (hasPrefix "/" $path) -}}
  24. {{- fail (printf "Container - Expected <%s> <path> to start with a forward slash [/] on <http> type" $caller) -}}
  25. {{- end -}}
  26. {{- with $objectData.type -}}
  27. {{- $scheme = tpl . $rootCtx -}}
  28. {{- end }}
  29. httpGet:
  30. {{- with $objectData.host }}
  31. host: {{ tpl . $rootCtx }}
  32. {{- end }}
  33. port: {{ $port }}
  34. path: {{ $path }}
  35. scheme: {{ $scheme | upper }}
  36. {{- with $objectData.httpHeaders }}
  37. httpHeaders:
  38. {{- range $name, $value := . }}
  39. {{- if not $value -}}
  40. {{- fail "Container - Expected non-empty <value> on <httpHeaders>" -}}
  41. {{- end }}
  42. - name: {{ $name }}
  43. value: {{ tpl (toString $value) $rootCtx | quote }}
  44. {{- end -}}
  45. {{- end -}}
  46. {{- end -}}