feat(common): Release common-3.1.0 (#303)

This commit is contained in:
Bernd Schorgers 2024-04-04 08:05:57 +02:00 committed by GitHub
parent 55b1b3a383
commit 11f1a43664
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 185 additions and 19 deletions

View file

@ -0,0 +1,130 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: controller revisionHistoryLimit
templates:
- common.yaml
values:
- ../_values/controllers_main_default_container.yaml
tests:
# Deployment
- it: default should pass for Deployment
set:
controllers.main.type: deployment
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.revisionHistoryLimit
value: 3
- it: custom revisionHistoryLimit should pass for Deployment
set:
controllers.main:
type: deployment
revisionHistoryLimit: 8
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.revisionHistoryLimit
value: 8
- it: explicit revisionHistoryLimit 0 should pass for Deployment
set:
controllers.main:
type: deployment
revisionHistoryLimit: 0
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.revisionHistoryLimit
value: 0
# StatefulSet
- it: default should pass for StatefulSet
set:
controllers.main.type: statefulset
asserts:
- documentIndex: 0
isKind:
of: StatefulSet
- documentIndex: 0
equal:
path: spec.revisionHistoryLimit
value: 3
- it: custom revisionHistoryLimit should pass for StatefulSet
set:
controllers.main:
type: statefulset
revisionHistoryLimit: 8
asserts:
- documentIndex: 0
isKind:
of: StatefulSet
- documentIndex: 0
equal:
path: spec.revisionHistoryLimit
value: 8
- it: explicit revisionHistoryLimit 0 should pass for StatefulSet
set:
controllers.main:
type: statefulset
revisionHistoryLimit: 0
asserts:
- documentIndex: 0
isKind:
of: StatefulSet
- documentIndex: 0
equal:
path: spec.revisionHistoryLimit
value: 0
# DaemonSet
- it: default should pass for DaemonSet
set:
controllers.main.type: daemonset
asserts:
- documentIndex: 0
isKind:
of: DaemonSet
- documentIndex: 0
equal:
path: spec.revisionHistoryLimit
value: 3
- it: custom revisionHistoryLimit should pass for DaemonSet
set:
controllers.main:
type: daemonset
revisionHistoryLimit: 8
asserts:
- documentIndex: 0
isKind:
of: DaemonSet
- documentIndex: 0
equal:
path: spec.revisionHistoryLimit
value: 8
- it: explicit revisionHistoryLimit 0 should pass for DaemonSet
set:
controllers.main:
type: daemonset
revisionHistoryLimit: 0
asserts:
- documentIndex: 0
isKind:
of: DaemonSet
- documentIndex: 0
equal:
path: spec.revisionHistoryLimit
value: 0

View file

@ -52,6 +52,16 @@ tests:
equal: equal:
path: metadata.name path: metadata.name
value: RELEASE-NAME value: RELEASE-NAME
- documentIndex: *ServiceMonitorDocument
equal:
path: spec.namespaceSelector
value:
matchNames:
- NAMESPACE
- documentIndex: *ServiceMonitorDocument
equal:
path: spec.jobLabel
value: RELEASE-NAME
- documentIndex: *ServiceMonitorDocument - documentIndex: *ServiceMonitorDocument
equal: equal:
path: spec.selector.matchLabels path: spec.selector.matchLabels

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.4 version: 3.1.0
kubeVersion: ">=1.22.0-0" kubeVersion: ">=1.22.0-0"
keywords: keywords:
- common - common
@ -16,4 +16,10 @@ annotations:
artifacthub.io/changes: |- artifacthub.io/changes: |-
- kind: fixed - kind: fixed
description: |- description: |-
Improved fix for preventing potential incorrect controller references Fixed `default` function overriding `0` values
- kind: fixed
description: |-
Fixed missing `volumeName` field in persistence schema
- kind: added
description: |-
Add jobLabel and namespaceSelector to serviceMonitor

View file

@ -1,6 +1,6 @@
# common # common
![Version: 3.0.4](https://img.shields.io/badge/Version-3.0.4-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![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)
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.4 version: 3.1.0
repository: https://bjw-s.github.io/helm-charts/ repository: https://bjw-s.github.io/helm-charts/
``` ```
@ -50,4 +50,4 @@ These values will be validated by a JSON schema which can be found [here](https:
- Join the home-operations [Discord](https://discord.gg/home-operations) community - Join the home-operations [Discord](https://discord.gg/home-operations) community
---------------------------------------------- ----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.12.0](https://github.com/norwoodj/helm-docs/releases/v1.12.0) Autogenerated from chart metadata using [helm-docs v1.13.1](https://github.com/norwoodj/helm-docs/releases/v1.13.1)

View file

@ -51,6 +51,9 @@
"storageClass": { "storageClass": {
"type": "string" "type": "string"
}, },
"volumeName": {
"type": "string"
},
"advancedMounts": {"$ref": "#/advancedMounts"}, "advancedMounts": {"$ref": "#/advancedMounts"},
"globalMounts": {"$ref": "#/globalMounts"} "globalMounts": {"$ref": "#/globalMounts"}
}, },

View file

@ -36,13 +36,13 @@ metadata:
spec: spec:
suspend: {{ default false $cronJobSettings.suspend }} suspend: {{ default false $cronJobSettings.suspend }}
concurrencyPolicy: {{ default "Forbid" $cronJobSettings.concurrencyPolicy }} concurrencyPolicy: {{ default "Forbid" $cronJobSettings.concurrencyPolicy }}
startingDeadlineSeconds: {{ default 30 $cronJobSettings.startingDeadlineSeconds }} startingDeadlineSeconds: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $cronJobSettings.startingDeadlineSeconds "default" 30) }}
{{- with $timeZone }} {{- with $timeZone }}
timeZone: {{ . }} timeZone: {{ . }}
{{- end }} {{- end }}
schedule: {{ $cronJobSettings.schedule | quote }} schedule: {{ $cronJobSettings.schedule | quote }}
successfulJobsHistoryLimit: {{ default 1 $cronJobSettings.successfulJobsHistory }} successfulJobsHistoryLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $cronJobSettings.successfulJobsHistory "default" 1) }}
failedJobsHistoryLimit: {{ default 1 $cronJobSettings.failedJobsHistory }} failedJobsHistoryLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $cronJobSettings.failedJobsHistory "default" 1) }}
jobTemplate: jobTemplate:
spec: spec:
{{- with $cronJobSettings.ttlSecondsAfterFinished }} {{- with $cronJobSettings.ttlSecondsAfterFinished }}
@ -51,7 +51,7 @@ spec:
{{- with $cronJobSettings.parallelism }} {{- with $cronJobSettings.parallelism }}
parallelism: {{ . }} parallelism: {{ . }}
{{- end }} {{- end }}
backoffLimit: {{ default 6 $cronJobSettings.backoffLimit }} backoffLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $cronJobSettings.backoffLimit "default" 6) }}
template: template:
metadata: metadata:
{{- with (include "bjw-s.common.lib.pod.metadata.annotations" (dict "rootContext" $rootContext "controllerObject" $cronjobObject)) }} {{- with (include "bjw-s.common.lib.pod.metadata.annotations" (dict "rootContext" $rootContext "controllerObject" $cronjobObject)) }}

View file

@ -27,7 +27,7 @@ metadata:
annotations: {{- toYaml . | nindent 4 -}} annotations: {{- toYaml . | nindent 4 -}}
{{- end }} {{- end }}
spec: spec:
revisionHistoryLimit: {{ default 3 $daemonsetObject.revisionHistoryLimit }} revisionHistoryLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $daemonsetObject.revisionHistoryLimit "default" 3) }}
selector: selector:
matchLabels: matchLabels:
app.kubernetes.io/component: {{ $daemonsetObject.identifier }} app.kubernetes.io/component: {{ $daemonsetObject.identifier }}

View file

@ -27,7 +27,7 @@ metadata:
annotations: {{- toYaml . | nindent 4 -}} annotations: {{- toYaml . | nindent 4 -}}
{{- end }} {{- end }}
spec: spec:
revisionHistoryLimit: {{ default 3 $deploymentObject.revisionHistoryLimit }} revisionHistoryLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $deploymentObject.revisionHistoryLimit "default" 3) }}
{{- if hasKey $deploymentObject "replicas" }} {{- if hasKey $deploymentObject "replicas" }}
{{- if not (eq $deploymentObject.replicas nil) }} {{- if not (eq $deploymentObject.replicas nil) }}
replicas: {{ $deploymentObject.replicas }} replicas: {{ $deploymentObject.replicas }}

View file

@ -42,7 +42,7 @@ spec:
{{- with $jobSettings.completionMode }} {{- with $jobSettings.completionMode }}
completionMode: {{ . }} completionMode: {{ . }}
{{- end }} {{- end }}
backoffLimit: {{ default 6 $jobSettings.backoffLimit }} backoffLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $jobSettings.backoffLimit "default" 6) }}
template: template:
metadata: metadata:
{{- with (include "bjw-s.common.lib.pod.metadata.annotations" (dict "rootContext" $rootContext "controllerObject" $jobObject)) }} {{- with (include "bjw-s.common.lib.pod.metadata.annotations" (dict "rootContext" $rootContext "controllerObject" $jobObject)) }}

View file

@ -64,7 +64,7 @@ spec:
name: {{ default .name $service.name }} name: {{ default .name $service.name }}
namespace: {{ default $rootContext.Release.Namespace .namespace }} namespace: {{ default $rootContext.Release.Namespace .namespace }}
port: {{ default .port $servicePrimaryPort.port }} port: {{ default .port $servicePrimaryPort.port }}
weight: {{ default 1 .weight }} weight: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" .weight "default" 1) }}
{{- end }} {{- end }}
{{- if or (eq $routeKind "HTTPRoute") (eq $routeKind "GRPCRoute") }} {{- if or (eq $routeKind "HTTPRoute") (eq $routeKind "GRPCRoute") }}
{{- with .matches }} {{- with .matches }}

View file

@ -21,6 +21,10 @@ metadata:
annotations: {{- toYaml . | nindent 4 -}} annotations: {{- toYaml . | nindent 4 -}}
{{- end }} {{- end }}
spec: spec:
jobLabel: "{{ $serviceMonitorObject.name }}"
namespaceSelector:
matchNames:
- {{ $rootContext.Release.Namespace }}
selector: selector:
{{- if $serviceMonitorObject.selector -}} {{- if $serviceMonitorObject.selector -}}
{{- tpl ($serviceMonitorObject.selector | toYaml) $rootContext | nindent 4}} {{- tpl ($serviceMonitorObject.selector | toYaml) $rootContext | nindent 4}}

View file

@ -27,7 +27,7 @@ metadata:
annotations: {{- toYaml . | nindent 4 -}} annotations: {{- toYaml . | nindent 4 -}}
{{- end }} {{- end }}
spec: spec:
revisionHistoryLimit: {{ default 3 $statefulsetObject.revisionHistoryLimit }} revisionHistoryLimit: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $statefulsetObject.revisionHistoryLimit "default" 3) }}
replicas: {{ $statefulsetObject.replicas }} replicas: {{ $statefulsetObject.replicas }}
podManagementPolicy: {{ dig "statefulset" "podManagementPolicy" "OrderedReady" $statefulsetObject }} podManagementPolicy: {{ dig "statefulset" "podManagementPolicy" "OrderedReady" $statefulsetObject }}
updateStrategy: updateStrategy:

View file

@ -0,0 +1,13 @@
{{/*
Return the value or the specified default if the given value is null.
*/}}
{{- define "bjw-s.common.lib.defaultKeepNonNullValue" -}}
{{- $value := .value -}}
{{- $default := required "default value is required" .default -}}
{{- if eq nil $value -}}
{{- $default | toYaml -}}
{{- else -}}
{{- $value | toYaml -}}
{{- end -}}
{{- end }}

View file

@ -39,10 +39,10 @@ Probes used by the container.
{{- $probeType = $probeValues.type | default "TCP" -}} {{- $probeType = $probeValues.type | default "TCP" -}}
{{- end -}} {{- end -}}
{{- $_ := set $probeDefinition "initialDelaySeconds" (default 0 $probeSpec.initialDelaySeconds) -}} {{- $_ := set $probeDefinition "initialDelaySeconds" (include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $probeSpec.initialDelaySeconds "default" 0) | int) -}}
{{- $_ := set $probeDefinition "failureThreshold" (default 3 $probeSpec.failureThreshold) -}} {{- $_ := set $probeDefinition "failureThreshold" (include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $probeSpec.failureThreshold "default" 3) | int) -}}
{{- $_ := set $probeDefinition "timeoutSeconds" (default 1 $probeSpec.timeoutSeconds) -}} {{- $_ := set $probeDefinition "timeoutSeconds" (include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $probeSpec.timeoutSeconds "default" 1) | int) -}}
{{- $_ := set $probeDefinition "periodSeconds" (default 10 $probeSpec.periodSeconds) -}} {{- $_ := set $probeDefinition "periodSeconds" (include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" $probeSpec.periodSeconds "default" 10) | int) -}}
{{- $probeHeader := "" -}} {{- $probeHeader := "" -}}
{{- if or ( eq $probeType "HTTPS" ) ( eq $probeType "HTTP" ) -}} {{- if or ( eq $probeType "HTTPS" ) ( eq $probeType "HTTP" ) -}}

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