Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/helm_lib/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
type: library
name: deckhouse_lib_helm
version: 1.71.10
version: 1.71.11
description: "Helm utils template definitions for Deckhouse modules."
4 changes: 3 additions & 1 deletion charts/helm_lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -681,11 +681,13 @@ list:

#### Usage

`{{ include "helm_lib_envs_for_proxy" . }} `
`{{ include "helm_lib_envs_for_proxy" . }} or {{ include "helm_lib_envs_for_proxy" (list . (list "extra1" "extra2")) }} `

#### Arguments

list:
- Template context with .Values, .Chart, etc
- List of additional NO_PROXY entries (optional)

## High Availability

Expand Down
17 changes: 15 additions & 2 deletions charts/helm_lib/templates/_envs_for_proxy.tpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
{{- /* Usage: {{ include "helm_lib_envs_for_proxy" . }} */ -}}
{{- /* Usage: {{ include "helm_lib_envs_for_proxy" . }} or {{ include "helm_lib_envs_for_proxy" (list . (list "extra1" "extra2")) }} */ -}}
{{- /* Add HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment variables for container */ -}}
{{- /* depends on [proxy settings](https://deckhouse.io/products/kubernetes-platform/documentation/v1/reference/api/global.html#parameters-modules-proxy) */ -}}
{{- define "helm_lib_envs_for_proxy" }}
{{- $context := . -}} {{- /* Template context with .Values, .Chart, etc */ -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
{{- /* List of additional NO_PROXY entries (optional) */ -}}
{{- $context := . -}}
{{- $extraNoProxy := list -}}

{{- /* If a list is passed, then the first element is the context, and the second is the extraNoProxy list. */ -}}
{{- if kindIs "slice" . }}
{{- $context = index . 0 -}}
{{- $extraNoProxy = index . 1 -}}
{{- end }}

{{- if $context.Values.global.clusterConfiguration }}
{{- if $context.Values.global.clusterConfiguration.proxy }}
{{- if $context.Values.global.clusterConfiguration.proxy.httpProxy }}
Expand All @@ -21,6 +31,9 @@
{{- if $context.Values.global.clusterConfiguration.proxy.noProxy }}
{{- $noProxy = concat $noProxy $context.Values.global.clusterConfiguration.proxy.noProxy }}
{{- end }}
{{- if $extraNoProxy }}
{{- $noProxy = concat $noProxy $extraNoProxy }}
{{- end }}
- name: NO_PROXY
value: {{ $noProxy | join "," | quote }}
- name: no_proxy
Expand Down
4 changes: 3 additions & 1 deletion tests/templates/helm_lib_envs_for_proxy.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
proxyEnvs:
{{ include "helm_lib_envs_for_proxy" . }}
{{ include "helm_lib_envs_for_proxy" . }}
proxyEnvsWithExtra:
{{ include "helm_lib_envs_for_proxy" (list . (list "extra1" "extra2")) }}
28 changes: 27 additions & 1 deletion tests/tests/helm_lib_envs_for_proxy_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ tests:
- equal:
path: "proxyEnvs[5].value"
value: "127.0.0.1,169.254.169.254,registry.d8-system.svc,cluster.local,10.0.0.0/16,10.1.0.0/16,example.com"
- equal:
path: "proxyEnvsWithExtra[4].name"
value: "NO_PROXY"
- equal:
path: "proxyEnvsWithExtra[4].value"
value: "127.0.0.1,169.254.169.254,registry.d8-system.svc,cluster.local,10.0.0.0/16,10.1.0.0/16,example.com,extra1,extra2"
- equal:
path: "proxyEnvsWithExtra[5].name"
value: "no_proxy"
- equal:
path: "proxyEnvsWithExtra[5].value"
value: "127.0.0.1,169.254.169.254,registry.d8-system.svc,cluster.local,10.0.0.0/16,10.1.0.0/16,example.com,extra1,extra2"

- it: should render proxy env vars with only http proxy
set:
Expand Down Expand Up @@ -86,6 +98,18 @@ tests:
- equal:
path: "proxyEnvs[3].value"
value: "127.0.0.1,169.254.169.254,registry.d8-system.svc,cluster.local,10.0.0.0/16,10.1.0.0/16"
- equal:
path: "proxyEnvsWithExtra[2].name"
value: "NO_PROXY"
- equal:
path: "proxyEnvsWithExtra[2].value"
value: "127.0.0.1,169.254.169.254,registry.d8-system.svc,cluster.local,10.0.0.0/16,10.1.0.0/16,extra1,extra2"
- equal:
path: "proxyEnvsWithExtra[3].name"
value: "no_proxy"
- equal:
path: "proxyEnvsWithExtra[3].value"
value: "127.0.0.1,169.254.169.254,registry.d8-system.svc,cluster.local,10.0.0.0/16,10.1.0.0/16,extra1,extra2"

- it: should not render proxy env vars when no proxy configured
set:
Expand All @@ -96,4 +120,6 @@ tests:
serviceSubnetCIDR: "10.1.0.0/16"
asserts:
- isEmpty:
path: "proxyEnvs"
path: "proxyEnvs"
- isEmpty:
path: "proxyEnvsWithExtra"
Loading