Quellcode durchsuchen

refactor: rename VIRTUAL_HOST_YAML -> VIRTUAL_HOST_MULTIPORTS

Nicolas Duchon vor 1 Jahr
Ursprung
Commit
47e2838e61
2 geänderte Dateien mit 12 neuen und 9 gelöschten Zeilen
  1. 8 5
      nginx.tmpl
  2. 4 4
      test/test_multiports/test_multiports-base.yml

+ 8 - 5
nginx.tmpl

@@ -495,8 +495,8 @@ proxy_set_header X-Original-URI $request_uri;
 proxy_set_header Proxy "";
 {{- end }}
 
-{{- /* Precompute some information about vhost that use VIRTUAL_HOST_YAML. */}}
-{{- range $vhosts_yaml, $containers := groupBy $globals.containers "Env.VIRTUAL_HOST_YAML" }}
+{{- /* Precompute and store some information about vhost that use VIRTUAL_HOST_MULTIPORTS. */}}
+{{- range $vhosts_yaml, $containers := groupBy $globals.containers "Env.VIRTUAL_HOST_MULTIPORTS" }}
     {{- range $hostname, $vhost := (fromYaml $vhosts_yaml) }}
         {{- $vhost_data := when (hasKey $globals.vhosts $hostname) (get $globals.vhosts $hostname) (dict) }}
         {{- $paths := coalesce $vhost_data.paths (dict) }}
@@ -529,7 +529,7 @@ proxy_set_header Proxy "";
     {{- end }}
 {{- end }}
 
-{{- /* Precompute some information about vhost that use VIRTUAL_HOST. */}}
+{{- /* Precompute and store some information about vhost that use VIRTUAL_HOST. */}}
 {{- range $hostname, $containers := groupByMulti $globals.containers "Env.VIRTUAL_HOST" "," }}
     {{- /* Ignore containers with VIRTUAL_HOST set to the empty string. */}}
     {{- $hostname = trim $hostname }}
@@ -537,8 +537,10 @@ proxy_set_header Proxy "";
         {{- continue }}
     {{- end }}
 
-    {{/* Drop containers with VIRTUAL_HOST_YAML set (VIRTUAL_HOST_YAML takes precedence). */}}
-    {{- range $_, $containers_to_drop := groupBy $containers "Env.VIRTUAL_HOST_YAML" }}
+    {{- /* Drop containers with both VIRTUAL_HOST and VIRTUAL_HOST_MULTIPORTS set
+         * (VIRTUAL_HOST_MULTIPORTS takes precedence thanks to the previous loop).
+         */}}
+    {{- range $_, $containers_to_drop := groupBy $containers "Env.VIRTUAL_HOST_MULTIPORTS" }}
         {{- range $container := $containers_to_drop }}
             {{- $containers = without $containers $container }}
         {{- end }}
@@ -575,6 +577,7 @@ proxy_set_header Proxy "";
     {{- $_ := set $globals.vhosts $hostname $vhost_data }}
 {{- end }}
 
+{{- /* Loop over $globals.vhosts and update it with the remaining informations about each vhost. */}}
 {{- range $hostname, $vhost_data := $globals.vhosts }}
     {{- $vhost_containers := list }}
     {{- range $path, $vpath_data := $vhost_data.paths }}

+ 4 - 4
test/test_multiports/test_multiports-base.yml

@@ -8,7 +8,7 @@ services:
     environment:
       WEB_PORTS: "81"
       VIRTUAL_HOST: skipped.nginx-proxy.tld
-      VIRTUAL_HOST_YAML: |-
+      VIRTUAL_HOST_MULTIPORTS: |-
         notskipped.nginx-proxy.tld:
 
   defaultport:
@@ -18,7 +18,7 @@ services:
       - "8080"
     environment:
       WEB_PORTS: "80 8080"
-      VIRTUAL_HOST_YAML: |-
+      VIRTUAL_HOST_MULTIPORTS: |-
         port80.a.nginx-proxy.tld:
         port80.b.nginx-proxy.tld:
         port80.c.nginx-proxy.tld:
@@ -31,7 +31,7 @@ services:
       - "9000"
     environment:
       WEB_PORTS: "8080 9000"
-      VIRTUAL_HOST_YAML: |-
+      VIRTUAL_HOST_MULTIPORTS: |-
         port8080.nginx-proxy.tld:
           "/":
             port: 8080
@@ -46,7 +46,7 @@ services:
       - "10002"
     environment:
       WEB_PORTS: "10001 10002"
-      VIRTUAL_HOST_YAML: |-
+      VIRTUAL_HOST_MULTIPORTS: |-
         virtualpaths.nginx-proxy.tld:
           "/rootdest":
             port: 10001