Skip to content

Commit

Permalink
helm: template function compatibility for automatic lookup
Browse files Browse the repository at this point in the history
This commit ensures that the `helm template` function does not error when the configuration is set to
```
k8sServiceHost: auto
```
Fixes: cilium#35094

Signed-off-by: Kevin Reeuwijk <[email protected]>
  • Loading branch information
kreeuwijk authored and joestringer committed Oct 4, 2024
1 parent 3f7360a commit f12dca7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions install/kubernetes/cilium/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ To override the namespace and configMap when using `auto`:
`.Values.k8sServiceLookupNamespace` and `.Values.k8sServiceLookupConfigMapName`
*/}}
{{- define "k8sServiceHost" }}
{{- if eq .Values.k8sServiceHost "auto" }}
{{- $configmapName := default "cluster-info" .Values.k8sServiceLookupConfigMapName }}
{{- $configmapNamespace := default "kube-public" .Values.k8sServiceLookupNamespace }}
{{- $configmapName := default "cluster-info" .Values.k8sServiceLookupConfigMapName }}
{{- $configmapNamespace := default "kube-public" .Values.k8sServiceLookupNamespace }}
{{- if and (eq .Values.k8sServiceHost "auto") (lookup "v1" "ConfigMap" $configmapNamespace $configmapName) }}
{{- $configmap := (lookup "v1" "ConfigMap" $configmapNamespace $configmapName) }}
{{- $kubeconfig := get $configmap.data "kubeconfig" }}
{{- $k8sServer := get ($kubeconfig | fromYaml) "clusters" | mustFirst | dig "cluster" "server" "" }}
Expand All @@ -149,9 +149,9 @@ To override the namespace and configMap when using `auto`:
`.Values.k8sServiceLookupNamespace` and `.Values.k8sServiceLookupConfigMapName`
*/}}
{{- define "k8sServicePort" }}
{{- if eq .Values.k8sServiceHost "auto" }}
{{- $configmapName := default "cluster-info" .Values.k8sServiceLookupConfigMapName }}
{{- $configmapNamespace := default "kube-public" .Values.k8sServiceLookupNamespace }}
{{- $configmapName := default "cluster-info" .Values.k8sServiceLookupConfigMapName }}
{{- $configmapNamespace := default "kube-public" .Values.k8sServiceLookupNamespace }}
{{- if and (eq .Values.k8sServiceHost "auto") (lookup "v1" "ConfigMap" $configmapNamespace $configmapName) }}
{{- $configmap := (lookup "v1" "ConfigMap" $configmapNamespace $configmapName) }}
{{- $kubeconfig := get $configmap.data "kubeconfig" }}
{{- $k8sServer := get ($kubeconfig | fromYaml) "clusters" | mustFirst | dig "cluster" "server" "" }}
Expand Down

0 comments on commit f12dca7

Please sign in to comment.