feat(common): Release common-3.0.2

This commit is contained in:
Bernd Schorgers 2024-03-11 21:33:52 +01:00
parent 1e00c7f252
commit e20623adf9
No known key found for this signature in database
GPG key ID: BC5E2BD907F9A8EC
16 changed files with 127 additions and 22 deletions

View file

@ -87,3 +87,21 @@ tests:
equal: equal:
path: metadata.name path: metadata.name
value: RELEASE-NAME-http value: RELEASE-NAME-http
- it: with templated nameOverride should pass
set:
configMaps:
config:
data:
test: test
nameOverride: "{{ .Release.Name }}"
asserts:
- hasDocuments:
count: 2
- documentIndex: &ConfigmapDocument 1
isKind:
of: ConfigMap
- documentIndex: *ConfigmapDocument
equal:
path: metadata.name
value: RELEASE-NAME

View file

@ -56,6 +56,8 @@ tests:
- it: additional controllers with nameOverride should pass - it: additional controllers with nameOverride should pass
set: set:
controllers: controllers:
main:
nameOverride: "{{ .Release.Name }}"
second: second:
nameOverride: testOverride nameOverride: testOverride
containers: containers:
@ -72,7 +74,7 @@ tests:
- documentIndex: *firstDeploymentDoc - documentIndex: *firstDeploymentDoc
equal: equal:
path: metadata.name path: metadata.name
value: RELEASE-NAME-main value: RELEASE-NAME
- documentIndex: *firstDeploymentDoc - documentIndex: *firstDeploymentDoc
equal: equal:
path: metadata.labels['app.kubernetes.io/component'] path: metadata.labels['app.kubernetes.io/component']

View file

@ -23,6 +23,32 @@ tests:
path: spec.rules[0].http.paths[0].path path: spec.rules[0].http.paths[0].path
value: "/" value: "/"
- it: nameOverride should pass
set:
ingress.main:
nameOverride: test
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: metadata.name
value: RELEASE-NAME-test
- it: nameOverride with template should pass
set:
ingress.main:
nameOverride: "{{ .Release.Name }}"
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: metadata.name
value: RELEASE-NAME
- it: custom host and path should pass - it: custom host and path should pass
set: set:
ingress.main: ingress.main:

View file

@ -32,6 +32,20 @@ tests:
path: metadata.name path: metadata.name
value: RELEASE-NAME-http value: RELEASE-NAME-http
- it: custom name suffix with template should pass
values:
- ../_values/service_main_default.yaml
set:
service.main.nameOverride: "{{ .Release.Name }}"
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: metadata.name
value: RELEASE-NAME
- it: multiple should pass - it: multiple should pass
values: values:
- ../_values/service_main_default.yaml - ../_values/service_main_default.yaml

View file

@ -3,7 +3,7 @@ apiVersion: v2
name: common name: common
description: Function library for Helm charts description: Function library for Helm charts
type: library type: library
version: 3.0.1 version: 3.0.2
kubeVersion: ">=1.22.0-0" kubeVersion: ">=1.22.0-0"
keywords: keywords:
- common - common
@ -14,6 +14,9 @@ maintainers:
email: me@bjw-s.dev email: me@bjw-s.dev
annotations: annotations:
artifacthub.io/changes: |- artifacthub.io/changes: |-
- kind: fixed
description: |-
Fixed nameOverride logic to prevent duplicated name
- kind: changed - kind: changed
description: |- description: |-
BREAKING: Default objects (they used to be called main) have been commented out and will therefore no longer provide any (both expected and unexpected) default values. BREAKING: Default objects (they used to be called main) have been commented out and will therefore no longer provide any (both expected and unexpected) default values.

View file

@ -1,6 +1,6 @@
# common # common
![Version: 3.0.1](https://img.shields.io/badge/Version-3.0.1-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![Version: 3.0.2](https://img.shields.io/badge/Version-3.0.2-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square)
Function library for Helm charts Function library for Helm charts
@ -27,7 +27,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
# Chart.yaml # Chart.yaml
dependencies: dependencies:
- name: common - name: common
version: 3.0.1 version: 3.0.2
repository: https://bjw-s.github.io/helm-charts/ repository: https://bjw-s.github.io/helm-charts/
``` ```

View file

@ -10,9 +10,14 @@ Convert configMap values to an object
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}} {{- if $objectValues.nameOverride -}}
{{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}} {{- else -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- $_ := set $objectValues "name" $objectName -}} {{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}} {{- $_ := set $objectValues "identifier" $identifier -}}

View file

@ -15,11 +15,16 @@ Convert controller values to an object
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}} {{- if $objectValues.nameOverride -}}
{{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}} {{- else -}}
{{- $enabledControllers := (include "bjw-s.common.lib.controller.enabledControllers" (dict "rootContext" $rootContext) | fromYaml ) }} {{- $enabledControllers := (include "bjw-s.common.lib.controller.enabledControllers" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if gt (len $enabledControllers) 1 -}} {{- if gt (len $enabledControllers) 1 -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- $_ := set $objectValues "name" $objectName -}} {{- $_ := set $objectValues "name" $objectName -}}

View file

@ -10,11 +10,16 @@ Convert ingress values to an object
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}} {{- if $objectValues.nameOverride -}}
{{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}} {{- else -}}
{{- $enabledIngresses := (include "bjw-s.common.lib.ingress.enabledIngresses" (dict "rootContext" $rootContext) | fromYaml ) }} {{- $enabledIngresses := (include "bjw-s.common.lib.ingress.enabledIngresses" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if gt (len $enabledIngresses) 1 -}} {{- if gt (len $enabledIngresses) 1 -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- $_ := set $objectValues "name" $objectName -}} {{- $_ := set $objectValues "name" $objectName -}}

View file

@ -10,11 +10,16 @@ Convert networkPolicy values to an object
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}} {{- if $objectValues.nameOverride -}}
{{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}} {{- else -}}
{{- $enabledNetworkPolicies := (include "bjw-s.common.lib.networkPolicy.enabledNetworkPolicies" (dict "rootContext" $rootContext) | fromYaml ) }} {{- $enabledNetworkPolicies := (include "bjw-s.common.lib.networkPolicy.enabledNetworkPolicies" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if gt (len $enabledNetworkPolicies) 1 -}} {{- if gt (len $enabledNetworkPolicies) 1 -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- $_ := set $objectValues "name" $objectName -}} {{- $_ := set $objectValues "name" $objectName -}}

View file

@ -14,7 +14,9 @@ Convert PVC values to an object
{{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}}
{{- end -}} {{- end -}}
{{- else -}} {{- else -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- $_ := set $objectValues "name" $objectName -}} {{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}} {{- $_ := set $objectValues "identifier" $identifier -}}

View file

@ -10,10 +10,15 @@ Convert Route values to an object
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}} {{- if $objectValues.nameOverride -}}
{{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}} {{- else -}}
{{- if ne $identifier (include "bjw-s.common.lib.route.primary" $rootContext) -}} {{- if ne $identifier (include "bjw-s.common.lib.route.primary" $rootContext) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- $_ := set $objectValues "name" $objectName -}} {{- $_ := set $objectValues "name" $objectName -}}

View file

@ -10,9 +10,14 @@ Convert Secret values to an object
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}} {{- if $objectValues.nameOverride -}}
{{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}} {{- else -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- $_ := set $objectValues "name" $objectName -}} {{- $_ := set $objectValues "name" $objectName -}}
{{- $_ := set $objectValues "identifier" $identifier -}} {{- $_ := set $objectValues "identifier" $identifier -}}

View file

@ -10,11 +10,16 @@ Convert Service values to an object
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}} {{- if $objectValues.nameOverride -}}
{{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}} {{- else -}}
{{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" (dict "rootContext" $rootContext) | fromYaml ) }} {{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if and (not $objectValues.primary) (gt (len $enabledServices) 1) -}} {{- if and (not $objectValues.primary) (gt (len $enabledServices) 1) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- $_ := set $objectValues "name" $objectName -}} {{- $_ := set $objectValues "name" $objectName -}}

View file

@ -10,11 +10,16 @@ Convert ServiceMonitor values to an object
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}} {{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
{{- if $objectValues.nameOverride -}} {{- if $objectValues.nameOverride -}}
{{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- $override := tpl $objectValues.nameOverride $rootContext -}}
{{- if not (eq $objectName $override) -}}
{{- $objectName = printf "%s-%s" $objectName $override -}}
{{- end -}}
{{- else -}} {{- else -}}
{{- $enabledServiceMonitors := (include "bjw-s.common.lib.serviceMonitor.enabledServiceMonitors" (dict "rootContext" $rootContext) | fromYaml ) }} {{- $enabledServiceMonitors := (include "bjw-s.common.lib.serviceMonitor.enabledServiceMonitors" (dict "rootContext" $rootContext) | fromYaml ) }}
{{- if gt (len $enabledServiceMonitors) 1 -}} {{- if gt (len $enabledServiceMonitors) 1 -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- if not (eq $objectName $identifier) -}}
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{- $_ := set $objectValues "name" $objectName -}} {{- $_ := set $objectValues "name" $objectName -}}

View file

@ -1,6 +1,6 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema", "$schema": "http://json-schema.org/draft-07/schema",
"$id": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.0.1/charts/library/common/values.schema.json", "$id": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.0.2/charts/library/common/values.schema.json",
"type": "object", "type": "object",
"properties": { "properties": {