feat(common)!: Release v3.0.0-beta4 (#282)

This commit is contained in:
Bernd Schorgers 2024-03-10 17:08:43 +01:00 committed by GitHub
parent ea9484a7fd
commit a27c4f6124
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 283 additions and 157 deletions

View file

@ -1,3 +1,5 @@
---
# yaml-language-server: $schema=../../common/values.schema.json
controllers: controllers:
main: main:
containers: containers:
@ -53,7 +55,7 @@ service:
controller: main controller: main
ports: ports:
http: http:
port: 8081 port: 8887
ingress: ingress:
main: main:

View file

@ -1,3 +1,5 @@
---
# yaml-language-server: $schema=../../common/values.schema.json
controllers: controllers:
main: main:
containers: containers:
@ -28,6 +30,13 @@ ingress:
- hosts: - hosts:
- "test.local" - "test.local"
service:
main:
controller: main
ports:
http:
port: 8080
persistence: persistence:
media: media:
type: persistentVolumeClaim type: persistentVolumeClaim

View file

@ -1,3 +1,5 @@
---
# yaml-language-server: $schema=../../common/values.schema.json
controllers: controllers:
main: main:
type: cronjob type: cronjob
@ -11,10 +13,6 @@ controllers:
tag: 31 tag: 31
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
service:
main:
enabled: false
configMaps: configMaps:
config: config:
enabled: true enabled: true

View file

@ -1,3 +1,5 @@
---
# yaml-language-server: $schema=../../common/values.schema.json
controllers: controllers:
main: main:
containers: containers:
@ -6,15 +8,3 @@ controllers:
repository: ghcr.io/mendhak/http-https-echo repository: ghcr.io/mendhak/http-https-echo
tag: 31 tag: 31
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
service:
main:
enabled: false
probes:
liveness:
enabled: false
readiness:
enabled: false
startup:
enabled: false

View file

@ -1,3 +1,5 @@
---
# yaml-language-server: $schema=../../common/values.schema.json
controllers: controllers:
main: main:
strategy: Recreate strategy: Recreate
@ -22,6 +24,7 @@ controllers:
# -- Configures service settings for the chart. # -- Configures service settings for the chart.
service: service:
main: main:
controller: main
ports: ports:
http: http:
port: 80 port: 80

View file

@ -0,0 +1,73 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: persistence configmap
templates:
- common.yaml
tests:
- it: configmap persistence type should pass
set:
persistence:
configmap:
type: configMap
name: mySettings
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: configmap
configMap:
name: mySettings
- it: configmap persistence type with name template should pass
set:
persistence:
configmap:
type: configMap
name: '{{ include "bjw-s.common.lib.chart.names.fullname" $ }}-config'
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: configmap
configMap:
name: RELEASE-NAME-config
- it: configmap persistence type with identifier reference should pass
set:
configMaps:
mySettings:
data:
test: testvalue
persistence:
configmap:
type: configMap
identifier: mySettings
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: configmap
configMap:
name: RELEASE-NAME-mySettings
- it: configmap persistence type with invalid identifier reference should fail
set:
persistence:
configmap:
type: configMap
identifier: doesNotExist
asserts:
- failedTemplate:
errorMessage: "No configmap found with this identifier. (persistence item 'configmap', identifier 'doesNotExist')"

View file

@ -0,0 +1,32 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: persistence custom
templates:
- common.yaml
tests:
- it: custom persistence type should pass
set:
persistence:
custom-mount:
enabled: true
type: custom
volumeSpec:
downwardAPI:
items:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: custom-mount
downwardAPI:
items:
- fieldRef:
fieldPath: metadata.labels
path: labels

View file

@ -0,0 +1,26 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: persistence nfs
templates:
- common.yaml
tests:
- it: nfs persistence type should pass
set:
persistence:
nfs:
enabled: true
type: nfs
server: 10.10.0.8
path: /tank/nas/library
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: nfs
nfs:
path: /tank/nas/library
server: 10.10.0.8

View file

@ -0,0 +1,75 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: persistence secret
templates:
- common.yaml
tests:
- it: secret persistence type should pass
set:
persistence:
secret:
enabled: true
type: secret
name: mySettings
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: secret
secret:
secretName: mySettings
- it: secret persistence type with name template should pass
set:
persistence:
secret:
enabled: true
type: secret
name: "{{ .Release.Name }}-config"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: secret
secret:
secretName: RELEASE-NAME-config
- it: secret persistence type with identifier reference should pass
set:
secrets:
mySettings:
stringData:
test: testvalue
persistence:
secret:
type: secret
identifier: mySettings
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: secret
secret:
secretName: RELEASE-NAME-mySettings
- it: secret persistence type with invalid identifier reference should fail
set:
persistence:
secret:
type: secret
identifier: doesNotExist
asserts:
- failedTemplate:
errorMessage: "No secret found with this identifier. (persistence item 'secret', identifier 'doesNotExist')"

View file

@ -1,129 +0,0 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: persistence types
templates:
- common.yaml
tests:
- it: custom persistence type should pass
set:
persistence:
custom-mount:
enabled: true
type: custom
volumeSpec:
downwardAPI:
items:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: custom-mount
downwardAPI:
items:
- fieldRef:
fieldPath: metadata.labels
path: labels
- it: configmap persistence type should pass
set:
persistence:
configmap:
enabled: true
type: configMap
name: mySettings
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: configmap
configMap:
name: mySettings
- it: configmap persistence type with name template should pass
set:
persistence:
configmap:
enabled: true
type: configMap
name: '{{ include "bjw-s.common.lib.chart.names.fullname" $ }}-config'
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: configmap
configMap:
name: RELEASE-NAME-config
- it: secret persistence type should pass
set:
persistence:
secret:
enabled: true
type: secret
name: mySettings
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: secret
secret:
secretName: mySettings
- it: secret persistence type with name template should pass
set:
persistence:
secret:
enabled: true
type: secret
name: "{{ .Release.Name }}-config"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: secret
secret:
secretName: RELEASE-NAME-config
- it: nfs persistence type should pass
set:
persistence:
nfs:
enabled: true
type: nfs
server: 10.10.0.8
path: /tank/nas/library
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: nfs
nfs:
path: /tank/nas/library
server: 10.10.0.8

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.0-beta3 version: 3.0.0-beta4
kubeVersion: ">=1.22.0-0" kubeVersion: ">=1.22.0-0"
keywords: keywords:
- common - common
@ -19,10 +19,13 @@ annotations:
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. 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.
- kind: changed - kind: changed
description: |- description: |-
enableServiceLinks is disabled by default enableServiceLinks is now disabled by default
- kind: added - kind: added
description: |- description: |-
Added support for restartPolicy field on container level Added support for restartPolicy field on container level
- kind: added - kind: added
description: |- description: |-
Added json-schema to the chart Added json-schema to the chart
- kind: added
description: |-
Allow referencing secrets and configMaps by identifier in persistence section

View file

@ -93,10 +93,21 @@
"name": { "name": {
"type": "string" "type": "string"
}, },
"identifier": {
"type": "string"
},
"advancedMounts": {"$ref": "#/advancedMounts"}, "advancedMounts": {"$ref": "#/advancedMounts"},
"globalMounts": {"$ref": "#/globalMounts"} "globalMounts": {"$ref": "#/globalMounts"}
}, },
"required": ["name"] "oneOf": [{"required": ["name"]}, {"required": ["identifier"]}],
"dependencies": {
"name": {
"not": {"required": ["identifier"]}
},
"identifier": {
"not": {"required": ["name"]}
}
}
}, },
"secretItem": { "secretItem": {
@ -114,10 +125,21 @@
"name": { "name": {
"type": "string" "type": "string"
}, },
"identifier": {
"type": "string"
},
"advancedMounts": {"$ref": "#/advancedMounts"}, "advancedMounts": {"$ref": "#/advancedMounts"},
"globalMounts": {"$ref": "#/globalMounts"} "globalMounts": {"$ref": "#/globalMounts"}
}, },
"required": ["name"] "oneOf": [{"required": ["name"]}, {"required": ["identifier"]}],
"dependencies": {
"name": {
"not": {"required": ["identifier"]}
},
"identifier": {
"not": {"required": ["name"]}
}
}
}, },
"nfsItem": { "nfsItem": {

View file

@ -58,8 +58,16 @@ Returns the value for volumes
{{- /* configMap persistence type */ -}} {{- /* configMap persistence type */ -}}
{{- else if eq $persistenceValues.type "configMap" -}} {{- else if eq $persistenceValues.type "configMap" -}}
{{- $objectName := (required (printf "name not set for persistence item %s" $identifier) $persistenceValues.name) -}} {{- $objectName := "" -}}
{{- $objectName = tpl $objectName $rootContext -}} {{- if $persistenceValues.name -}}
{{- $objectName = tpl $persistenceValues.name $rootContext -}}
{{- else if $persistenceValues.identifier -}}
{{- $object := (include "bjw-s.common.lib.configMap.getByIdentifier" (dict "rootContext" $rootContext "id" $persistenceValues.identifier) | fromYaml ) -}}
{{- if not $object -}}
{{fail (printf "No configmap found with this identifier. (persistence item '%s', identifier '%s')" $identifier $persistenceValues.identifier)}}
{{- end -}}
{{- $objectName = $object.name -}}
{{- end -}}
{{- $_ := set $volume "configMap" dict -}} {{- $_ := set $volume "configMap" dict -}}
{{- $_ := set $volume.configMap "name" $objectName -}} {{- $_ := set $volume.configMap "name" $objectName -}}
{{- with $persistenceValues.defaultMode -}} {{- with $persistenceValues.defaultMode -}}
@ -71,8 +79,16 @@ Returns the value for volumes
{{- /* Secret persistence type */ -}} {{- /* Secret persistence type */ -}}
{{- else if eq $persistenceValues.type "secret" -}} {{- else if eq $persistenceValues.type "secret" -}}
{{- $objectName := (required (printf "name not set for persistence item %s" $identifier) $persistenceValues.name) -}} {{- $objectName := "" -}}
{{- $objectName = tpl $objectName $rootContext -}} {{- if $persistenceValues.name -}}
{{- $objectName = tpl $persistenceValues.name $rootContext -}}
{{- else if $persistenceValues.identifier -}}
{{- $object := (include "bjw-s.common.lib.secret.getByIdentifier" (dict "rootContext" $rootContext "id" $persistenceValues.identifier) | fromYaml ) -}}
{{- if not $object -}}
{{fail (printf "No secret found with this identifier. (persistence item '%s', identifier '%s')" $identifier $persistenceValues.identifier)}}
{{- end -}}
{{- $objectName = $object.name -}}
{{- end -}}
{{- $_ := set $volume "secret" dict -}} {{- $_ := set $volume "secret" dict -}}
{{- $_ := set $volume.secret "secretName" $objectName -}} {{- $_ := set $volume.secret "secretName" $objectName -}}
{{- with $persistenceValues.defaultMode -}} {{- with $persistenceValues.defaultMode -}}

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

View file

@ -10,10 +10,13 @@ In order to mount a configMap to a mount point within the Pod you can use the
| Field | Mandatory | Docs / Description | | Field | Mandatory | Docs / Description |
| ------------- | --------- | -------------------------------------------------------------------------- | | ------------- | --------- | -------------------------------------------------------------------------- |
| `name` | Yes | Which configMap should be mounted. Supports Helm templating. | | `name` | No | Which configMap should be mounted. Supports Helm templating. |
| `identifier` | No | Reference a configMap from the `configMaps` key by its identifier. |
| `defaultMode` | No | The default file access permission bit. | | `defaultMode` | No | The default file access permission bit. |
| `items` | No | Specify item-specific configuration. Will be passed 1:1 to the volumeSpec. | | `items` | No | Specify item-specific configuration. Will be passed 1:1 to the volumeSpec. |
Either `name` or `identifier` is required.
!!! note !!! note
Even if not specified, the configMap will be read-only. Even if not specified, the configMap will be read-only.

View file

@ -10,10 +10,13 @@ In order to mount a Secret to a mount point within the Pod you can use the
| Field | Mandatory | Docs / Description | | Field | Mandatory | Docs / Description |
| ------------- | --------- | -------------------------------------------------------------------------- | | ------------- | --------- | -------------------------------------------------------------------------- |
| `name` | Yes | Which Secret should be mounted. Supports Helm templating. | | `name` | No | Which Secret should be mounted. Supports Helm templating. |
| `identifier` | No | Reference a Secret from the `secrets` key by its identifier. |
| `defaultMode` | No | The default file access permission bit. | | `defaultMode` | No | The default file access permission bit. |
| `items` | No | Specify item-specific configuration. Will be passed 1:1 to the volumeSpec. | | `items` | No | Specify item-specific configuration. Will be passed 1:1 to the volumeSpec. |
Either `name` or `identifier` is required.
!!! note !!! note
Even if not specified, the Secret will be read-only. Even if not specified, the Secret will be read-only.