Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create listen directives using template helper functions #4234

Closed
shaun-nx opened this issue Aug 15, 2023 · 1 comment
Closed

Create listen directives using template helper functions #4234

shaun-nx opened this issue Aug 15, 2023 · 1 comment
Assignees
Milestone

Comments

@shaun-nx
Copy link
Contributor

shaun-nx commented Aug 15, 2023

This proposal aims to remove much of the business logic/logical conditions from our template files and move them into go functions. This aims to make the code more testable and easier to expand.

Example of current template file for custom listeners:

      {{ if not $s.CustomListeners }}
  listen 80{{ if $s.ProxyProtocol }} proxy_protocol{{ end }};
  {{ if not $s.DisableIPV6 }}listen [::]:80{{ if $s.ProxyProtocol }} proxy_protocol{{ end }};{{ end }}
      {{ else }}
      {{ if (gt $s.HTTPPort 0) }}
  listen {{ $s.HTTPPort }}{{ if $s.ProxyProtocol }} proxy_protocol{{ end }};
  {{ if not $s.DisableIPV6 }}listen [::]:{{ $s.HTTPPort }}{{ if $s.ProxyProtocol }} proxy_protocol{{ end }};{{ end }}
      {{ end }}
      {{ end }}

Example of template file for customer listeners after adding template helper function:

{{ makeListener $s.Listener $s.CustomListeners | printf }}

The code for makeListener will reside in a function in internal/configs/version1/template_helper.go

@github-actions
Copy link

Hi @shaun-nx thanks for reporting!

Be sure to check out the docs and the Contributing Guidelines while you wait for a human to take a look at this 🙂

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants