feat(common): Release 3.2.0 (#318)

Signed-off-by: Gavin Mogan <git@gavinmogan.com>
Co-authored-by: Gavin Mogan <git@gavinmogan.com>
Co-authored-by: repo-duster[bot] <87358111+repo-duster[bot]@users.noreply.github.com>
This commit is contained in:
Bernd Schorgers 2024-05-23 11:54:12 +02:00 committed by GitHub
parent 6cbaa61a4f
commit 4a5f448abd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 248 additions and 53 deletions

View file

@ -31,13 +31,11 @@ jobs:
chart: ${{ fromJSON(inputs.chartsToTest) }} chart: ${{ fromJSON(inputs.chartsToTest) }}
k8s_version: k8s_version:
[ [
"v1.23.17", "v1.26.15",
"v1.24.17", "v1.27.13",
"v1.25.16", "v1.28.9",
"v1.26.13", "v1.29.4",
"v1.27.10", "v1.30.0",
"v1.28.6",
"v1.29.1",
] ]
fail-fast: false fail-fast: false
steps: steps:

View file

@ -16,6 +16,10 @@ tests:
test_default_enabled: test_default_enabled:
data: data:
test: value 1 test: value 1
test_not_in_checksum:
includeInChecksum: false
data:
test: value 1
test_disabled: test_disabled:
enabled: false enabled: false
data: data:

View file

@ -82,3 +82,34 @@ tests:
global_label: test global_label: test
helm.sh/chart: common-test-1.0.0 helm.sh/chart: common-test-1.0.0
test_label: test test_label: test
- it: custom metadata with templates should pass
set:
ingress.main:
annotations:
template_annotation1: "{{ .Release.Name | lower }}"
template_annotation2: "{{ .Chart.Name | lower }}"
labels:
template_label1: "{{ .Release.Name | lower }}"
template_label2: "{{ .Chart.Name | lower }}"
asserts:
- documentIndex: &IngressDocument 1
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: metadata.annotations["template_annotation1"]
value: release-name
- documentIndex: *IngressDocument
equal:
path: metadata.annotations["template_annotation2"]
value: common-test
- documentIndex: *IngressDocument
equal:
path: metadata.labels["template_label1"]
value: release-name
- documentIndex: *IngressDocument
equal:
path: metadata.labels["template_label2"]
value: common-test

View file

@ -44,3 +44,42 @@ tests:
equal: equal:
path: metadata.name path: metadata.name
value: RELEASE-NAME-block-ingress value: RELEASE-NAME-block-ingress
- it: multiple networkpolicies can be enabled
set:
networkpolicies:
primary:
controller: main
policyTypes:
- Ingress
- Egress
rules: {}
secondary:
controller: main
policyTypes:
- Ingress
- Egress
rules: {}
asserts:
- hasDocuments:
count: 3
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: &firstNetworkPolicyDocument 1
isKind:
of: NetworkPolicy
- documentIndex: *firstNetworkPolicyDocument
equal:
path: metadata.name
value: RELEASE-NAME-primary
- documentIndex: 2
isKind:
of: NetworkPolicy
- documentIndex: &secondNetworkPolicyDocument 2
isKind:
of: NetworkPolicy
- documentIndex: *secondNetworkPolicyDocument
equal:
path: metadata.name
value: RELEASE-NAME-secondary

View file

@ -16,6 +16,10 @@ tests:
stringData: stringData:
test_1: value 1 test_1: value 1
test_2: value 2 test_2: value 2
test_not_in_checksum:
includeInChecksum: false
stringData:
test: value 1
test_disabled: test_disabled:
enabled: false enabled: false
stringData: stringData:

View file

@ -153,7 +153,7 @@ tests:
main: main:
selector: selector:
matchExpressions: matchExpressions:
test: "true" - {key: k8s-app, operator: Exists}
endpoints: endpoints:
- port: http - port: http
scheme: http scheme: http
@ -175,7 +175,8 @@ tests:
path: spec.selector path: spec.selector
value: value:
matchExpressions: matchExpressions:
test: "true" - key: k8s-app
operator: Exists
- it: a serviceMonitor is created with targetLabels - it: a serviceMonitor is created with targetLabels
set: set:

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.1.0 version: 3.2.0
kubeVersion: ">=1.22.0-0" kubeVersion: ">=1.22.0-0"
keywords: keywords:
- common - common
@ -14,12 +14,18 @@ maintainers:
email: me@bjw-s.dev email: me@bjw-s.dev
annotations: annotations:
artifacthub.io/changes: |- artifacthub.io/changes: |-
- kind: fixed
description: |-
Fixed `default` function overriding `0` values
- kind: fixed
description: |-
Fixed missing `volumeName` field in persistence schema
- kind: added - kind: added
description: |- description: |-
Add jobLabel and namespaceSelector to serviceMonitor Support templating in annotation and label values for all objects
- kind: added
description: |-
Support activeDeadlineSeconds field on CronJobs and Jobs
- kind: added
description: |-
Support excluding secrets and configMaps from pod checksum annotation
- kind: fixed
description: |-
Fixed failing ServiceMonitor test
- kind: fixed
description: |-
Fixed networkPolicies not rendering correctly

View file

@ -1,6 +1,6 @@
# common # common
![Version: 3.1.0](https://img.shields.io/badge/Version-3.1.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![Version: 3.2.0](https://img.shields.io/badge/Version-3.2.0-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.1.0 version: 3.2.0
repository: https://bjw-s.github.io/helm-charts/ repository: https://bjw-s.github.io/helm-charts/
``` ```

View file

@ -7,6 +7,10 @@
"type": "boolean", "type": "boolean",
"default": true "default": true
}, },
"includeInChecksum": {
"type": "boolean",
"default": true
},
"annotations": { "annotations": {
"$ref": "definitions.json#/annotations" "$ref": "definitions.json#/annotations"
}, },

View file

@ -229,6 +229,9 @@
"timeZone": { "timeZone": {
"type": "string" "type": "string"
}, },
"activeDeadlineSeconds": {
"type": "integer"
},
"ttlSecondsAfterFinished": { "ttlSecondsAfterFinished": {
"type": "integer" "type": "integer"
} }
@ -254,6 +257,9 @@
"type": "boolean", "type": "boolean",
"default": false "default": false
}, },
"activeDeadlineSeconds": {
"type": "integer"
},
"ttlSecondsAfterFinished": { "ttlSecondsAfterFinished": {
"type": "integer" "type": "integer"
} }

View file

@ -7,6 +7,10 @@
"type": "boolean", "type": "boolean",
"default": true "default": true
}, },
"includeInChecksum": {
"type": "boolean",
"default": true
},
"annotations": { "annotations": {
"$ref": "definitions.json#/annotations" "$ref": "definitions.json#/annotations"
}, },

View file

@ -20,10 +20,16 @@ kind: ConfigMap
metadata: metadata:
name: {{ $configMapObject.name }} name: {{ $configMapObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
data: data:
{{- with $configMapObject.data }} {{- with $configMapObject.data }}

View file

@ -28,10 +28,16 @@ kind: CronJob
metadata: metadata:
name: {{ $cronjobObject.name }} name: {{ $cronjobObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
spec: spec:
suspend: {{ default false $cronJobSettings.suspend }} suspend: {{ default false $cronJobSettings.suspend }}
@ -45,6 +51,9 @@ spec:
failedJobsHistoryLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $cronJobSettings.failedJobsHistory "default" 1) }} failedJobsHistoryLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $cronJobSettings.failedJobsHistory "default" 1) }}
jobTemplate: jobTemplate:
spec: spec:
{{- with $cronJobSettings.activeDeadlineSeconds }}
activeDeadlineSeconds: {{ . }}
{{- end }}
{{- with $cronJobSettings.ttlSecondsAfterFinished }} {{- with $cronJobSettings.ttlSecondsAfterFinished }}
ttlSecondsAfterFinished: {{ . }} ttlSecondsAfterFinished: {{ . }}
{{- end }} {{- end }}

View file

@ -21,10 +21,16 @@ kind: DaemonSet
metadata: metadata:
name: {{ $daemonsetObject.name }} name: {{ $daemonsetObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
spec: spec:
revisionHistoryLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $daemonsetObject.revisionHistoryLimit "default" 3) }} revisionHistoryLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $daemonsetObject.revisionHistoryLimit "default" 3) }}

View file

@ -21,10 +21,16 @@ kind: Deployment
metadata: metadata:
name: {{ $deploymentObject.name }} name: {{ $deploymentObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
spec: spec:
revisionHistoryLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $deploymentObject.revisionHistoryLimit "default" 3) }} revisionHistoryLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $deploymentObject.revisionHistoryLimit "default" 3) }}

View file

@ -21,10 +21,16 @@ kind: Ingress
metadata: metadata:
name: {{ $ingressObject.name }} name: {{ $ingressObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
spec: spec:
{{- if $ingressObject.className }} {{- if $ingressObject.className }}

View file

@ -23,13 +23,22 @@ kind: Job
metadata: metadata:
name: {{ $jobObject.name }} name: {{ $jobObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
spec: spec:
suspend: {{ default false $jobSettings.suspend }} suspend: {{ default false $jobSettings.suspend }}
{{- with $jobSettings.activeDeadlineSeconds }}
activeDeadlineSeconds: {{ . }}
{{- end }}
{{- with $jobSettings.ttlSecondsAfterFinished }} {{- with $jobSettings.ttlSecondsAfterFinished }}
ttlSecondsAfterFinished: {{ . }} ttlSecondsAfterFinished: {{ . }}
{{- end }} {{- end }}

View file

@ -30,10 +30,16 @@ kind: NetworkPolicy
metadata: metadata:
name: {{ $networkPolicyObject.name }} name: {{ $networkPolicyObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
spec: spec:
podSelector: {{- toYaml $podSelector | nindent 4 }} podSelector: {{- toYaml $podSelector | nindent 4 }}

View file

@ -27,10 +27,16 @@ apiVersion: v1
metadata: metadata:
name: {{ $pvcObject.name }} name: {{ $pvcObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
spec: spec:
accessModes: accessModes:

View file

@ -28,10 +28,16 @@ kind: {{ $routeKind }}
metadata: metadata:
name: {{ $routeObject.name }} name: {{ $routeObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
spec: spec:
parentRefs: parentRefs:

View file

@ -28,10 +28,16 @@ type: {{ . }}
metadata: metadata:
name: {{ $secretObject.name }} name: {{ $secretObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
{{- with $stringData }} {{- with $stringData }}
stringData: {{- tpl $stringData $rootContext | nindent 2 }} stringData: {{- tpl $stringData $rootContext | nindent 2 }}

View file

@ -23,10 +23,16 @@ kind: Service
metadata: metadata:
name: {{ $serviceObject.name }} name: {{ $serviceObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
spec: spec:
{{- if (eq $svcType "ClusterIP") }} {{- if (eq $svcType "ClusterIP") }}

View file

@ -20,10 +20,16 @@ kind: ServiceAccount
metadata: metadata:
name: {{ $serviceAccountObject.name }} name: {{ $serviceAccountObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
secrets: secrets:
- name: {{ include "bjw-s.common.lib.chart.names.fullname" $rootContext }}-sa-token - name: {{ include "bjw-s.common.lib.chart.names.fullname" $rootContext }}-sa-token

View file

@ -15,10 +15,16 @@ kind: ServiceMonitor
metadata: metadata:
name: {{ $serviceMonitorObject.name }} name: {{ $serviceMonitorObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
spec: spec:
jobLabel: "{{ $serviceMonitorObject.name }}" jobLabel: "{{ $serviceMonitorObject.name }}"

View file

@ -21,10 +21,16 @@ kind: StatefulSet
metadata: metadata:
name: {{ $statefulsetObject.name }} name: {{ $statefulsetObject.name }}
{{- with $labels }} {{- with $labels }}
labels: {{- toYaml . | nindent 4 -}} labels:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
{{- with $annotations }} {{- with $annotations }}
annotations: {{- toYaml . | nindent 4 -}} annotations:
{{- range $key, $value := . }}
{{ $key }}: {{ tpl $value $rootContext }}
{{- end }}
{{- end }} {{- end }}
spec: spec:
revisionHistoryLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $statefulsetObject.revisionHistoryLimit "default" 3) }} revisionHistoryLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $statefulsetObject.revisionHistoryLimit "default" 3) }}

View file

@ -5,7 +5,7 @@ Return the enabled NetworkPolicies.
{{- $rootContext := .rootContext -}} {{- $rootContext := .rootContext -}}
{{- $enabledNetworkPolicies := dict -}} {{- $enabledNetworkPolicies := dict -}}
{{- range $name, $networkPolicy := $rootContext.Values.networkPolicy -}} {{- range $name, $networkPolicy := $rootContext.Values.networkpolicies -}}
{{- if kindIs "map" $networkPolicy -}} {{- if kindIs "map" $networkPolicy -}}
{{- /* Enable by default, but allow override */ -}} {{- /* Enable by default, but allow override */ -}}
{{- $networkPolicyEnabled := true -}} {{- $networkPolicyEnabled := true -}}

View file

@ -29,7 +29,11 @@ Returns the value for annotations
{{- if hasKey $configmap "enabled" -}} {{- if hasKey $configmap "enabled" -}}
{{- $configMapEnabled = $configmap.enabled -}} {{- $configMapEnabled = $configmap.enabled -}}
{{- end -}} {{- end -}}
{{- if $configMapEnabled -}} {{- $configMapIncludeInChecksum := true -}}
{{- if hasKey $configmap "includeInChecksum" -}}
{{- $configMapIncludeInChecksum = $configmap.includeInChecksum -}}
{{- end -}}
{{- if and $configMapEnabled $configMapIncludeInChecksum -}}
{{- $_ := set $configMapsFound $name (toYaml $configmap.data | sha256sum) -}} {{- $_ := set $configMapsFound $name (toYaml $configmap.data | sha256sum) -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
@ -47,7 +51,11 @@ Returns the value for annotations
{{- if hasKey $secret "enabled" -}} {{- if hasKey $secret "enabled" -}}
{{- $secretEnabled = $secret.enabled -}} {{- $secretEnabled = $secret.enabled -}}
{{- end -}} {{- end -}}
{{- if $secretEnabled -}} {{- $secretIncludeInChecksum := true -}}
{{- if hasKey $secret "includeInChecksum" -}}
{{- $secretIncludeInChecksum = $secret.includeInChecksum -}}
{{- end -}}
{{- if and $secretEnabled $secretIncludeInChecksum -}}
{{- $_ := set $secretsFound $name (toYaml $secret.stringData | sha256sum) -}} {{- $_ := set $secretsFound $name (toYaml $secret.stringData | sha256sum) -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}

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

View file

@ -496,10 +496,10 @@ ingress:
# # -- Override the name suffix that is used for this ingress. # # -- Override the name suffix that is used for this ingress.
# nameOverride: # nameOverride:
# # -- Provide additional annotations which may be required. # # -- Provide additional annotations which may be required. Helm templates can be used.
# annotations: {} # annotations: {}
# # -- Provide additional labels which may be required. # # -- Provide additional labels which may be required. Helm templates can be used.
# labels: {} # labels: {}
# # -- Set the ingressClass that is used for this ingress. # # -- Set the ingressClass that is used for this ingress.