_svcGen.tpl 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. {{- define "sftpgo.svc.gen" -}}
  2. {{- $rootCtx := .rootCtx -}}
  3. {{- $type := .type -}}
  4. {{- $enabledServices := (include "sftpgo.svc.enabled" (dict "rootCtx" $rootCtx "type" $type) | fromJsonArray) -}}
  5. {{- with $enabledServices }}
  6. {{ printf "sftpgo-%s" $type }}:
  7. enabled: true
  8. type: NodePort
  9. targetSelector: sftpgo
  10. ports:
  11. {{- end -}}
  12. {{- range $idx, $svc := $enabledServices }}
  13. {{ printf "%s-%d" $type $idx }}:
  14. enabled: true
  15. primary: {{ eq ($idx | int) 0 }}
  16. port: {{ $svc.port }}
  17. nodePort: {{ $svc.port }}
  18. targetSelector: sftpgo
  19. {{- end -}}
  20. {{- if and $enabledServices (eq $type "ftpd") -}}
  21. {{- $start := int $rootCtx.Values.sftpgoNetwork.ftpdPassivePortRange.start -}}
  22. {{- $end := int $rootCtx.Values.sftpgoNetwork.ftpdPassivePortRange.end -}}
  23. {{- $end = int (add1 $end) -}}
  24. {{- range $idx := untilStep $start $end 1 }}
  25. {{ printf "ftpd-pasv-%d" $idx }}:
  26. enabled: true
  27. port: {{ $idx }}
  28. nodePort: {{ $idx }}
  29. targetSelector: sftpgo
  30. {{- end -}}
  31. {{- end -}}
  32. {{- end -}}
  33. {{- define "sftpgo.svc.enabled" -}}
  34. {{- $rootCtx := .rootCtx -}}
  35. {{- $type := .type -}}
  36. {{- $services := (get $rootCtx.Values.sftpgoNetwork (printf "%sServices" $type)) -}}
  37. {{- $enabledServices := list -}}
  38. {{- if $services -}}
  39. {{- range $idx, $svc := $services -}}
  40. {{- if $svc.enabled -}}
  41. {{- $enabledServices = append $enabledServices $svc -}}
  42. {{- end -}}
  43. {{- end -}}
  44. {{- end -}}
  45. {{- $enabledServices | toJson -}}
  46. {{- end -}}