fix(common): Release v4.1.1 (#428)

This commit is contained in:
Bernd Schorgers 2025-06-12 13:19:46 +02:00 committed by GitHub
parent ce1c8adedb
commit 72cbacc0cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 88 additions and 39 deletions

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: 4.1.0 version: 4.1.1
kubeVersion: ">=1.28.0-0" kubeVersion: ">=1.28.0-0"
keywords: keywords:
- common - common
@ -18,25 +18,7 @@ annotations:
artifacthub.io/changes: |- artifacthub.io/changes: |-
- kind: fixed - kind: fixed
description: |- description: |-
Fixed a bug where probes were not being configured correctly for Services that autodetect their controller. Fixed an edge-case bug where specifying a merge defaultPodOptionsStrategy could crash the chart.
- kind: fixed - kind: fixed
description: |- description: |-
Fixed a bug where topologySpreadConstraints field did not properly render Helm templates. Fixed Route automatic service detection if there are no rules defined.
- kind: added
description: |-
Added support for configuring the `serviceName` field for StatefulSets.
- kind: added
description: |-
Added support for automatically selecting the ServiceAccount when only one is defined.
- kind: added
description: |-
- Added support for referencing target service for ServiceMonitors by identifier.
- kind: added
description: |-
Added support for automatically determining the target service for ServiceMonitors if there is only one enabled Service.
- kind: added
description: |-
Added support for always adding the identifier suffix even if there is only a single resource.
links:
- name: Updated documentation
url: https://bjw-s-labs.github.io/helm-charts/docs/common-library/resources/names/

View file

@ -1,6 +1,6 @@
# common # common
![Version: 4.1.0](https://img.shields.io/badge/Version-4.1.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![Version: 4.1.1](https://img.shields.io/badge/Version-4.1.1-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
@ -31,7 +31,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
# Chart.yaml # Chart.yaml
dependencies: dependencies:
- name: common - name: common
version: 4.1.0 version: 4.1.1
repository: https://bjw-s-labs.github.io/helm-charts/ repository: https://bjw-s-labs.github.io/helm-charts/
``` ```

View file

@ -5,32 +5,32 @@ Returns the value for the specified field
{{- $rootContext := .ctx.rootContext -}} {{- $rootContext := .ctx.rootContext -}}
{{- $controllerObject := .ctx.controllerObject -}} {{- $controllerObject := .ctx.controllerObject -}}
{{- $option := .option -}} {{- $option := .option -}}
{{- $default := default "" .default -}} {{- $default := default nil .default -}}
{{- $value := $default -}} {{- $value := $default -}}
{{- $defaultPodOptionsStrategy := dig "defaultPodOptionsStrategy" "overwrite" $rootContext.Values -}} {{- $defaultPodOptionsStrategy := dig "defaultPodOptionsStrategy" "overwrite" $rootContext.Values -}}
{{- /* Set to the default if it is set */ -}} {{- /* Set to the default Pod option if one is set */ -}}
{{- $defaultOption := dig $option nil (default dict $rootContext.Values.defaultPodOptions) -}} {{- $defaultPodOption := dig $option nil (default dict $rootContext.Values.defaultPodOptions) -}}
{{- if kindIs "bool" $defaultOption -}} {{- if kindIs "bool" $defaultPodOption -}}
{{- $value = $defaultOption -}} {{- $value = $defaultPodOption -}}
{{- else if not (empty $defaultOption) -}} {{- else if not (empty $defaultPodOption) -}}
{{- $value = $defaultOption -}} {{- $value = $defaultPodOption -}}
{{- end -}} {{- end -}}
{{- /* See if a pod-specific override is needed */ -}} {{- /* See if a pod-specific override is needed */ -}}
{{- $podOption := dig $option nil (default dict $controllerObject.pod) -}} {{- $podSpecificOption := dig $option nil (default dict $controllerObject.pod) -}}
{{- if kindIs "bool" $podOption -}} {{- if kindIs "bool" $podSpecificOption -}}
{{- $value = $podOption -}} {{- $value = $podSpecificOption -}}
{{- else if kindIs "map" $podOption -}} {{- else if kindIs "map" $podSpecificOption -}}
{{- if eq "merge" $defaultPodOptionsStrategy -}} {{- if eq "merge" $defaultPodOptionsStrategy -}}
{{- $value = merge $podOption $value -}} {{- $value = merge $podSpecificOption $value -}}
{{- else if eq "overwrite" $defaultPodOptionsStrategy -}} {{- else if eq "overwrite" $defaultPodOptionsStrategy -}}
{{- $value = $podOption -}} {{- $value = $podSpecificOption -}}
{{- end -}} {{- end -}}
{{- else if not (empty $podOption) -}} {{- else if not (empty $podSpecificOption) -}}
{{- $value = $podOption -}} {{- $value = $podSpecificOption -}}
{{- end -}} {{- end -}}
{{- if kindIs "bool" $value -}} {{- if kindIs "bool" $value -}}

View file

@ -7,6 +7,10 @@ Autodetects the service for a Route object
{{- $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 eq 1 (len $enabledServices) -}} {{- if eq 1 (len $enabledServices) -}}
{{- if empty $routeObject.rules -}}
{{- $_ := set $routeObject "rules" (list (dict "backendRefs" (list dict))) -}}
{{- end -}}
{{- range $routeObject.rules -}} {{- range $routeObject.rules -}}
{{- range .backendRefs }} {{- range .backendRefs }}
{{- $backendRef := . -}} {{- $backendRef := . -}}

View file

@ -47,3 +47,21 @@ tests:
path: spec.template.spec.nodeSelector path: spec.template.spec.nodeSelector
value: value:
disktype: hdd disktype: hdd
- it: empty defaultPodOptions with pod override can be merged
set:
defaultPodOptionsStrategy: merge
defaultPodOptions: {}
controllers:
main:
pod:
nodeSelector:
location: apartment
documentSelector:
path: $[?(@.kind == "Deployment")].metadata.name
value: release-name
asserts:
- equal:
path: spec.template.spec.nodeSelector
value:
location: apartment

View file

@ -136,3 +136,48 @@ tests:
statusCode: 301 statusCode: 301
- notExists: - notExists:
path: spec.rules[0].backendRefs[0] path: spec.rules[0].backendRefs[0]
- it: automatic service and port reference should pass with empty rules
values:
- ../_values/service_main_default.yaml
set:
route.main:
parentRefs:
- name: parentName
namespace: parentNamespace
rules: []
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- equal:
path: spec.rules[0].backendRefs[0]
value:
group: ""
kind: Service
name: release-name
namespace: NAMESPACE
port: 8081
weight: 1
- it: automatic service and port reference should pass with absent rules field
values:
- ../_values/service_main_default.yaml
set:
route.main:
parentRefs:
- name: parentName
namespace: parentNamespace
documentSelector:
path: $[?(@.kind == "HTTPRoute")].metadata.name
value: release-name
asserts:
- equal:
path: spec.rules[0].backendRefs[0]
value:
group: ""
kind: Service
name: release-name
namespace: NAMESPACE
port: 8081
weight: 1

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-labs/helm-charts/common-4.1.0/charts/library/common/values.schema.json", "$id": "https://raw.githubusercontent.com/bjw-s-labs/helm-charts/common-4.1.1/charts/library/common/values.schema.json",
"type": "object", "type": "object",
"properties": { "properties": {
"global": { "global": {