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
description: Function library for Helm charts
type: library
version: 4.1.0
version: 4.1.1
kubeVersion: ">=1.28.0-0"
keywords:
- common
@ -18,25 +18,7 @@ annotations:
artifacthub.io/changes: |-
- kind: fixed
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
description: |-
Fixed a bug where topologySpreadConstraints field did not properly render Helm templates.
- 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/
Fixed Route automatic service detection if there are no rules defined.

View file

@ -1,6 +1,6 @@
# 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
@ -31,7 +31,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
# Chart.yaml
dependencies:
- name: common
version: 4.1.0
version: 4.1.1
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 -}}
{{- $controllerObject := .ctx.controllerObject -}}
{{- $option := .option -}}
{{- $default := default "" .default -}}
{{- $default := default nil .default -}}
{{- $value := $default -}}
{{- $defaultPodOptionsStrategy := dig "defaultPodOptionsStrategy" "overwrite" $rootContext.Values -}}
{{- /* Set to the default if it is set */ -}}
{{- $defaultOption := dig $option nil (default dict $rootContext.Values.defaultPodOptions) -}}
{{- if kindIs "bool" $defaultOption -}}
{{- $value = $defaultOption -}}
{{- else if not (empty $defaultOption) -}}
{{- $value = $defaultOption -}}
{{- /* Set to the default Pod option if one is set */ -}}
{{- $defaultPodOption := dig $option nil (default dict $rootContext.Values.defaultPodOptions) -}}
{{- if kindIs "bool" $defaultPodOption -}}
{{- $value = $defaultPodOption -}}
{{- else if not (empty $defaultPodOption) -}}
{{- $value = $defaultPodOption -}}
{{- end -}}
{{- /* 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 -}}
{{- $value = $podOption -}}
{{- else if kindIs "map" $podOption -}}
{{- if kindIs "bool" $podSpecificOption -}}
{{- $value = $podSpecificOption -}}
{{- else if kindIs "map" $podSpecificOption -}}
{{- if eq "merge" $defaultPodOptionsStrategy -}}
{{- $value = merge $podOption $value -}}
{{- $value = merge $podSpecificOption $value -}}
{{- else if eq "overwrite" $defaultPodOptionsStrategy -}}
{{- $value = $podOption -}}
{{- $value = $podSpecificOption -}}
{{- end -}}
{{- else if not (empty $podOption) -}}
{{- $value = $podOption -}}
{{- else if not (empty $podSpecificOption) -}}
{{- $value = $podSpecificOption -}}
{{- end -}}
{{- 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 ) -}}
{{- if eq 1 (len $enabledServices) -}}
{{- if empty $routeObject.rules -}}
{{- $_ := set $routeObject "rules" (list (dict "backendRefs" (list dict))) -}}
{{- end -}}
{{- range $routeObject.rules -}}
{{- range .backendRefs }}
{{- $backendRef := . -}}

View file

@ -47,3 +47,21 @@ tests:
path: spec.template.spec.nodeSelector
value:
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
- notExists:
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",
"$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",
"properties": {
"global": {