mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-04 22:41:22 -03:00
Squashed commits: [040b37be] moar fixes (+6 squashed commit) Squashed commit: [5660a13b] hmm [afd1ed6c] more fixes [1472ee60] no message [97561173] bump test [6fbd3f2a] bump minor and remove app url from portal [f38df91f] no message
115 lines
3.9 KiB
Smarty
115 lines
3.9 KiB
Smarty
{{/* Returns the primary Workload object */}}
|
|
{{- define "tc.v1.common.lib.util.chartcontext" -}}
|
|
{{/* Create defaults */}}
|
|
{{- $protocol := "https" -}}
|
|
{{- $host := "$node_ip" -}}
|
|
{{- $port := "443" -}}
|
|
{{- $url := "" -}}
|
|
{{- $podCIDR := "172.16.0.0/16" -}}
|
|
{{- $svcCIDR := "172.17.0.0/16" -}}
|
|
|
|
{{/* set temporary storage for ingress name and port */}}
|
|
{{- $targetIngress := "" -}}
|
|
{{- $selectedIngress := "" -}}
|
|
|
|
|
|
{{/* Get service, default to primary */}}
|
|
{{- $selectedService := fromYaml ( include "tc.v1.common.lib.helpers.getSelectedServiceValues" (dict "rootCtx" $ )) }}
|
|
|
|
{{/* read loadbalancer IP's for metallb */}}
|
|
{{- if eq $selectedService.type "LoadBalancer" -}}
|
|
{{- with $selectedService.loadBalancerIP -}}
|
|
{{- $host = toString . -}}
|
|
{{- end -}}
|
|
|
|
{{/* set temporary storage for port name and port */}}
|
|
{{- $targetPort := "" -}}
|
|
{{- $selectedPort := "" -}}
|
|
{{/* Fetch port values */}}
|
|
{{- $targetPort = include "tc.v1.common.lib.util.service.ports.primary" (dict "svcName" $selectedService.shortName "svcValues" $selectedService ) -}}
|
|
{{- $selectedPort = get $selectedService.ports $targetPort -}}
|
|
{{/* store port number */}}
|
|
{{- $port = $selectedPort.port -}}
|
|
{{- end -}}
|
|
|
|
{{/* Fetch ingress values */}}
|
|
{{- $targetIngress = ( include "tc.v1.common.lib.util.ingress.primary" $ ) -}}
|
|
{{- $selectedIngress = get $.Values.ingress $targetIngress -}}
|
|
|
|
{{/* store host from ingress number */}}
|
|
{{- if $selectedIngress -}}
|
|
{{- if $selectedIngress.enabled -}}
|
|
{{- with (index $selectedIngress.hosts 0) }}
|
|
{{- $host = .host -}}
|
|
{{- end }}
|
|
{{/* Get the port for the ingress entrypoint */}}
|
|
{{- $namespace := "tc-system" }}
|
|
{{- if $selectedIngress.ingressClassName }}
|
|
{{- $namespace := ( printf "ix-%s" $selectedIngress.ingressClassName ) }}
|
|
{{- end }}
|
|
{{- $traefikportalhook := lookup "v1" "ConfigMap" $namespace "portalhook" }}
|
|
{{- $entrypoint := "websecure" }}
|
|
{{- if $selectedIngress.entrypoint }}
|
|
{{- $entrypoint = $selectedIngress.entrypoint }}
|
|
{{- end }}
|
|
{{- if $traefikportalhook }}
|
|
{{- if ( index $traefikportalhook.data $entrypoint ) }}
|
|
{{- $port = ( index $traefikportalhook.data $entrypoint ) }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
|
|
{{- $port = ( toString $port ) -}}
|
|
|
|
{{/* sanitise */}}
|
|
{{- if eq $port "443" -}}
|
|
{{- $protocol = "https" -}}
|
|
{{- end -}}
|
|
|
|
{{- if eq $port "80" -}}
|
|
{{- $protocol = "http" -}}
|
|
{{- end -}}
|
|
|
|
{{- if or ( and ( eq $protocol "https" ) ( eq $port "443" ) ) ( and ( eq $protocol "http" ) ( eq $port "80" ) ) -}}
|
|
{{- $port = "" -}}
|
|
{{- end -}}
|
|
|
|
{{- $port = toString $port -}}
|
|
|
|
{{/* Construct URL*/}}
|
|
{{- if $port -}}
|
|
{{- $url = printf "%s://%s:%s%s" $protocol $host $port -}}
|
|
{{- else -}}
|
|
{{- $url = printf "%s://%s%s" $protocol $host -}}
|
|
{{- end -}}
|
|
|
|
{{/* TrueNAS SCALE specific code */}}
|
|
{{- if $.Values.ixChartContext -}}
|
|
{{- if $.Values.ixChartContext.kubernetes_config -}}
|
|
{{- $podCIDR = $.Values.ixChartContext.kubernetes_config.cluster_cidr -}}
|
|
{{- $svcCIDR = $.Values.ixChartContext.kubernetes_config.service_cidr -}}
|
|
{{- end -}}
|
|
{{- else -}}
|
|
{{/* TODO: Find ways to implement CIDR detection */}}
|
|
{{- end -}}
|
|
|
|
{{- if $.Values.chartContext -}}
|
|
{{- if $.Values.chartContext.APPURL -}}
|
|
{{- $url = $.Values.chartContext.APPURL -}}
|
|
{{- end -}}
|
|
|
|
{{- if $.Values.chartContext.podCIDR -}}
|
|
{{- $podCIDR = $.Values.chartContext.podCIDR -}}
|
|
{{- end -}}
|
|
|
|
{{- if $.Values.chartContext.svcCIDR -}}
|
|
{{- $svcCIDR = $.Values.chartContext.svcCIDR -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- $_ := set $.Values.chartContext "APPURL" $url -}}
|
|
{{- $_ := set $.Values.chartContext "podCIDR" $podCIDR -}}
|
|
{{- $_ := set $.Values.chartContext "svcCIDR" $svcCIDR -}}
|
|
{{- end -}}
|