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.2
version: 1.71.4
description: "Helm utils template definitions for Deckhouse modules."
52 changes: 33 additions & 19 deletions charts/helm_lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
| [helm_lib_application_container_security_context_read_only_root_filesystem_capabilities_drop_all_pss_restricted](#helm_lib_application_container_security_context_read_only_root_filesystem_capabilities_drop_all_pss_restricted) |
| **Csi Controller** |
| [helm_lib_csi_image_with_common_fallback](#helm_lib_csi_image_with_common_fallback) |
| **Default Gateway** |
| [helm_lib_default_gateway](#helm_lib_default_gateway) |
| **Dns Policy** |
| [helm_lib_dns_policy_bootstraping_state](#helm_lib_dns_policy_bootstraping_state) |
| **Enable Ds Eviction** |
Expand All @@ -56,13 +54,16 @@
| **Module Ephemeral Storage** |
| [helm_lib_module_ephemeral_storage_logs_with_extra](#helm_lib_module_ephemeral_storage_logs_with_extra) |
| [helm_lib_module_ephemeral_storage_only_logs](#helm_lib_module_ephemeral_storage_only_logs) |
| **Module Gateway** |
| [helm_lib_module_gateway](#helm_lib_module_gateway) |
| **Module Generate Common Name** |
| [helm_lib_module_generate_common_name](#helm_lib_module_generate_common_name) |
| **Module Https** |
| [helm_lib_module_uri_scheme](#helm_lib_module_uri_scheme) |
| [helm_lib_module_https_mode](#helm_lib_module_https_mode) |
| [helm_lib_module_https_cert_manager_cluster_issuer_name](#helm_lib_module_https_cert_manager_cluster_issuer_name) |
| [helm_lib_module_https_ingress_tls_enabled](#helm_lib_module_https_ingress_tls_enabled) |
| [helm_lib_module_https_route_tls_enabled](#helm_lib_module_https_route_tls_enabled) |
| [helm_lib_module_https_copy_custom_certificate](#helm_lib_module_https_copy_custom_certificate) |
| [helm_lib_module_https_secret_name](#helm_lib_module_https_secret_name) |
| **Module Image** |
Expand Down Expand Up @@ -491,22 +492,6 @@ list:
- Container raw name
- Kubernetes semantic version

## Default Gateway

### helm_lib_default_gateway

accepts a dict that is updated with current default gateway name and namespace

#### Usage

`{{- include "helm_lib_default_gateway" (list . $gateway) `

#### Arguments

list:
- Template context with .Values, .Chart, etc
- An empty dict to update with current default gateway name and namespace

## Dns Policy

### helm_lib_dns_policy_bootstraping_state
Expand Down Expand Up @@ -662,6 +647,22 @@ list:

- Template context with .Values, .Chart, etc

## Module Gateway

### helm_lib_module_gateway

accepts a dict that is updated with current gateway name and namespace

#### Usage

`{{- include "helm_lib_module_gateway" (list . $gateway) `

#### Arguments

list:
- Template context with .Values, .Chart, etc
- An empty dict to update with current default gateway name and namespace

## Module Generate Common Name

### helm_lib_module_generate_common_name
Expand Down Expand Up @@ -721,7 +722,7 @@ list:

### helm_lib_module_https_ingress_tls_enabled

returns not empty string if tls should enable for ingress
returns not empty string if tls should be enabled for the ingress

#### Usage

Expand All @@ -732,6 +733,19 @@ list:
- Template context with .Values, .Chart, etc


### helm_lib_module_https_route_tls_enabled

returns not empty string if tls should be enabled for the route

#### Usage

`{{ if (include "helm_lib_module_https_route_tls_enabled" .) }} `

#### Arguments

- Template context with .Values, .Chart, etc


### helm_lib_module_https_copy_custom_certificate

Renders secret with [custom certificate](https://deckhouse.io/products/kubernetes-platform/documentation/v1/reference/api/global.html#parameters-modules-https-customcertificate)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{{- /* Usage: {{- include "helm_lib_default_gateway" (list . $gateway) */ -}}
{{- /* accepts a dict that is updated with current default gateway name and namespace */ -}}
{{- define "helm_lib_default_gateway" -}}
{{- /* Usage: {{- include "helm_lib_module_gateway" (list . $gateway) */ -}}
{{- /* accepts a dict that is updated with current gateway name and namespace */ -}}
{{- define "helm_lib_module_gateway" -}}
{{- $context := index . 0 -}} {{- /* Template context with .Values, .Chart, etc */ -}}
{{- $result := index . 1 -}} {{- /* An empty dict to update with current default gateway name and namespace */ -}}
{{- $g := dict -}}

{{- if hasKey $context.Values.global.modules "gatewayAPIDefaultGateway" -}}
{{- $g = $context.Values.global.modules.gatewayAPIDefaultGateway -}}
{{- $module_values := (index $context.Values (include "helm_lib_module_camelcase_name" $context)) -}}

{{- if hasKey $module_values "gatewayAPIGateway" -}}
{{- $g = $module_values.gatewayAPIGateway -}}
{{- else if hasKey $context.Values.global.modules "gatewayAPIGateway" -}}
{{- $g = $context.Values.global.modules.gatewayAPIGateway -}}
{{- else if and (hasKey $context.Values.global "discovery") (hasKey $context.Values.global.discovery "gatewayAPIDefaultGateway") -}}
{{- $g = $context.Values.global.discovery.gatewayAPIDefaultGateway -}}
{{- end -}}
Expand Down
14 changes: 13 additions & 1 deletion charts/helm_lib/templates/_module_https.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ certManager:
{{- end -}}

{{- /* Usage: {{ if (include "helm_lib_module_https_ingress_tls_enabled" .) }} */ -}}
{{- /* returns not empty string if tls should enable for ingress */ -}}
{{- /* returns not empty string if tls should be enabled for the ingress */ -}}
{{- define "helm_lib_module_https_ingress_tls_enabled" -}}
{{- $context := . -}} {{- /* Template context with .Values, .Chart, etc */ -}}

Expand All @@ -119,6 +119,18 @@ certManager:
{{- end -}}
{{- end -}}

{{- /* Usage: {{ if (include "helm_lib_module_https_route_tls_enabled" .) }} */ -}}
{{- /* returns not empty string if tls should be enabled for the route */ -}}
{{- define "helm_lib_module_https_route_tls_enabled" -}}
{{- $context := . -}} {{- /* Template context with .Values, .Chart, etc */ -}}

{{- $mode := include "helm_lib_module_https_mode" $context -}}

{{- if or (eq "CertManager" $mode) (eq "CustomCertificate" $mode) -}}
not empty string
{{- end -}}
{{- end -}}

{{- /* Usage: {{ include "helm_lib_module_https_copy_custom_certificate" (list . "namespace" "secret_name_prefix") }} */ -}}
{{- /* Renders secret with [custom certificate](https://deckhouse.io/products/kubernetes-platform/documentation/v1/reference/api/global.html#parameters-modules-https-customcertificate) */ -}}
{{- /* in passed namespace with passed prefix */ -}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $gateway := dict -}}
{{- include "helm_lib_default_gateway" (list . $gateway) }}
{{- include "helm_lib_module_gateway" (list . $gateway) }}
result:
{{- if $gateway }}
name: {{ $gateway.name }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tls_enabled: {{ include "helm_lib_module_https_route_tls_enabled" . }}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
suite: helm_lib_default_gateway definition
suite: helm_lib_module_gateway definition
templates:
- helm_lib_default_gateway.yaml
- helm_lib_module_gateway.yaml
tests:
- it: should return an empty result if default gateway isn't discovered
set:
Expand Down Expand Up @@ -29,11 +29,11 @@ tests:
name: "d8"
namespace: "d8-alb-istio"

- it: should return a default gateway from the module config
- it: should return a gateway from the global modules config
set:
global:
modules:
gatewayAPIDefaultGateway:
gatewayAPIGateway:
name: "shared-gateway"
namespace: "d8-shared-gateway"
discovery:
Expand All @@ -46,3 +46,25 @@ tests:
value:
name: "shared-gateway"
namespace: "d8-shared-gateway"

- it: should return a gateway from the module config
set:
testModule:
gatewayAPIGateway:
name: "local-gateway"
namespace: "local-gateway"
global:
modules:
gatewayAPIGateway:
name: "shared-gateway"
namespace: "d8-shared-gateway"
discovery:
gatewayAPIDefaultGateway:
name: "d8"
namespace: "d8-alb-istio"
asserts:
- equal:
path: "result"
value:
name: "local-gateway"
namespace: "local-gateway"
51 changes: 51 additions & 0 deletions tests/tests/helm_lib_module_https_route_tls_enabled_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
suite: helm_lib_module_https_route_tls_enabled definition
templates:
- helm_lib_module_https_route_tls_enabled.yaml
set:
global:
modules:
https:
mode: "Disabled"
enabledModules: ["cert-manager"]
tests:
- it: should return not empty string for CertManager mode
set:
testModule:
https:
mode: "CertManager"
certManager:
clusterIssuerName: "letsencrypt"
asserts:
- equal:
path: "tls_enabled"
value: "not empty string"

- it: should return not empty string for CustomCertificate mode
set:
testModule:
https:
mode: "CustomCertificate"
asserts:
- equal:
path: "tls_enabled"
value: "not empty string"

- it: should return null for Disabled mode
set:
testModule:
https:
mode: "Disabled"
asserts:
- equal:
path: "tls_enabled"
value: null

- it: should return null for OnlyInURI mode
set:
testModule:
https:
mode: "OnlyInURI"
asserts:
- equal:
path: "tls_enabled"
value: null
Loading