Limit exposed ports in template to 10

This commit is contained in:
mikfar 2024-07-28 19:27:32 +01:00
parent 8d47458026
commit 0af1d397ec

View file

@ -125,7 +125,7 @@
*/}} */}}
{{- define "container_port" }} {{- define "container_port" }}
{{- /* If only 1 port exposed, use that as a default, else 80. */}} {{- /* If only 1 port exposed, use that as a default, else 80. */}}
# exposed ports:{{ range sortObjectsByKeysAsc $.container.Addresses "Port" }} {{ .Port }}/{{ .Proto }}{{ else }} (none){{ end }} # exposed ports:{{ $maxPorts := 5 }}{{ $count := 0 }}{{ range sortObjectsByKeysAsc $.container.Addresses "Port" }}{{ if lt $count $maxPorts }} {{ .Port }}/{{ .Proto }}{{ $count = add $count 1 }}{{ end }}{{ else }} (none){{ end }}
{{- $default_port := when (eq (len $.container.Addresses) 1) (first $.container.Addresses).Port "80" }} {{- $default_port := when (eq (len $.container.Addresses) 1) (first $.container.Addresses).Port "80" }}
# default port: {{ $default_port }} # default port: {{ $default_port }}
{{- $port := when (eq $.port "default") $default_port (when (eq $.port "legacy") (or $.container.Env.VIRTUAL_PORT $default_port) $.port) }} {{- $port := when (eq $.port "default") $default_port (when (eq $.port "legacy") (or $.container.Env.VIRTUAL_PORT $default_port) $.port) }}
@ -474,7 +474,7 @@ proxy_set_header Proxy "";
{{- range $hostname, $vhost := $parsedVhosts }} {{- range $hostname, $vhost := $parsedVhosts }}
{{- $vhost_data := when (hasKey $globals.vhosts $hostname) (get $globals.vhosts $hostname) (dict) }} {{- $vhost_data := when (hasKey $globals.vhosts $hostname) (get $globals.vhosts $hostname) (dict) }}
{{- $paths := coalesce $vhost_data.paths (dict) }} {{- $paths := coalesce $vhost_data.paths (dict) }}
{{- if (empty $vhost) }} {{- if (empty $vhost) }}
{{ $vhost = dict "/" (dict) }} {{ $vhost = dict "/" (dict) }}
{{- end }} {{- end }}