Skip to content

Commit

Permalink
Fix ADVERTISE_IP to work with structured ingress paths
Browse files Browse the repository at this point in the history
Moves ADVERTISE_IP logic to a helper function
Fixes the regression from #52
  • Loading branch information
UnstoppableMango committed Jan 18, 2024
1 parent 561cbec commit 827fd73
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
17 changes: 17 additions & 0 deletions charts/kube-plex/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,20 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a list of values for ADVERTISE_IP
*/}}
{{- define "advertiseIp" -}}
{{- $hosts := list -}}
{{- range .Values.ingress.hosts -}}
{{- if kindIs "string" . }}
{{- $hosts = printf "https://%s" . | append $hosts -}}
{{- $hosts = printf "https://%s:443" . | append $hosts -}}
{{- else }}
{{- $hosts = printf "https://%s" .host | append $hosts -}}
{{- $hosts = printf "https://%s:443" .host | append $hosts -}}
{{- end }}
{{- end -}}
{{ join "," $hosts }}
{{- end -}}
7 changes: 2 additions & 5 deletions charts/kube-plex/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,14 @@ spec:
# Fill ADVERTISE_IP section in plex automatically
{{- if (or (eq .Values.service.type "ClusterIP") (empty .Values.service.type)) }}
- name: ADVERTISE_IP
value: |
{{ if .Values.ingress.hosts }}https://{{ join ",https://" .Values.ingress.hosts }}{{ end }}
{{ if .Values.ingress.hosts }},https://{{ join ",https://" .Values.ingress.hosts }}:443{{ end }}
value: {{ include "advertiseIp" . }}
{{- else if eq .Values.service.type "LoadBalancer" }}
{{- if (or .Values.service.loadBalancerIP .Values.ingress.hosts (index .Values.service.annotations "dns.pfsense.org/hostname")) }}
- name: ADVERTISE_IP
value: |
{{ if .Values.service.loadBalancerIP }}https://{{ .Values.service.loadBalancerIP }}:32400{{ end }}
{{ if index .Values.service.annotations "dns.pfsense.org/hostname" }},https://{{ join ",https://" (splitList "," (index .Values.service.annotations "dns.pfsense.org/hostname")) }}:32400{{ end }}
{{ if .Values.ingress.hosts }},https://{{ join ",https://" .Values.ingress.hosts }}{{ end }}
{{ if .Values.ingress.hosts }},https://{{ join ",https://" .Values.ingress.hosts }}:443{{ end }}
{{ if .Values.ingress.hosts }},{{ include "advertiseIp" . }}{{ end }}
{{- end }}
{{- end }}
volumeMounts:
Expand Down

0 comments on commit 827fd73

Please sign in to comment.