feat(common): move fallbackDefaults to global section (#745)

**Description**
Does what it says on the tin

Fixes: #727

**⚙️ Type of change**

- [x] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [x] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [x] 🔃 Refactor of current code

**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ Checklist:**

- [x] ⚖️ My code follows the style guidelines of this project
- [x] 👀 I have performed a self-review of my own code
- [x] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [x] ⚠️ My changes generate no new warnings
- [x] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [x] ⬆️ I increased versions for any altered app according to semantic
versioning

** App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._

---------

Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
Co-authored-by: Stavros kois <s.kois@outlook.com>
This commit is contained in:
Kjeld Schouten
2024-03-10 16:09:20 +01:00
committed by GitHub
parent a46e105c80
commit 33b6249f86
24 changed files with 93 additions and 91 deletions

View File

@@ -3,7 +3,7 @@ appVersion: ""
dependencies:
- name: common
repository: file://../common
version: ~19.1.0
version: ~20.0.0
deprecated: false
description: Helper chart to test different use cases of the common library
home: https://github.com/truecharts/apps/tree/master/charts/library/common-test

View File

@@ -73,10 +73,9 @@ tests:
global:
fallbackDefaults:
pgVersion: "15"
fallbackDefaults:
vctAccessModes:
- ReadWriteMany
- ReadWriteOnce
vctAccessModes:
- ReadWriteMany
- ReadWriteOnce
cnpg:
my-pg:
enabled: true

View File

@@ -159,8 +159,9 @@ tests:
- it: should create pvc with storageClass not set, but have fallbackDefaults set
set:
fallbackDefaults:
storageClass: some-storage-class
global:
fallbackDefaults:
storageClass: some-storage-class
persistence:
my-volume1:
enabled: true

View File

@@ -57,9 +57,10 @@ tests:
# Failures
- it: should fail when DaemonSet and RWO volume from fallback
set:
fallbackDefaults:
accessModes:
- ReadWriteOnce
global:
fallbackDefaults:
accessModes:
- ReadWriteOnce
workload:
workload-name1:
enabled: true
@@ -76,9 +77,10 @@ tests:
- it: should fail when DaemonSet and RWO volume from persistence
set:
fallbackDefaults:
accessModes:
- ReadWriteMany
global:
fallbackDefaults:
accessModes:
- ReadWriteMany
workload:
workload-name1:
enabled: true

View File

@@ -69,10 +69,11 @@ tests:
- it: should create vct with changed fallback accessModes
set:
fallbackDefaults:
vctAccessModes:
- ReadWriteMany
- ReadWriteOnce
global:
fallbackDefaults:
vctAccessModes:
- ReadWriteMany
- ReadWriteOnce
persistence:
my-volume1:
enabled: true
@@ -220,8 +221,9 @@ tests:
- it: should create vct with storageClass not set, but have fallbackDefaults set
set:
fallbackDefaults:
storageClass: some-storage-class
global:
fallbackDefaults:
storageClass: some-storage-class
persistence:
my-volume1:
enabled: true

View File

@@ -15,7 +15,7 @@ maintainers:
name: common
sources: null
type: library
version: 19.1.1
version: 20.0.0
annotations:
artifacthub.io/category: "integration-delivery"
artifacthub.io/license: "BUSL-1.1"

View File

@@ -18,14 +18,14 @@ objectData:
{{- $rootCtx := .rootCtx -}}
{{- $objectData := .objectData -}}
{{- $retain := $rootCtx.Values.fallbackDefaults.pvcRetain -}}
{{- $retain := $rootCtx.Values.global.fallbackDefaults.pvcRetain -}}
{{- if not (kindIs "invalid" $objectData.retain) -}}
{{- $retain = $objectData.retain -}}
{{- end -}}
{{- $reclaimPolicy := ternary "Retain" "Delete" $retain -}}
{{- $pvcSize := $rootCtx.Values.fallbackDefaults.pvcSize -}}
{{- $pvcSize := $rootCtx.Values.global.fallbackDefaults.pvcSize -}}
{{- with $objectData.size -}}
{{- $pvcSize = tpl . $rootCtx -}}
{{- end }}

View File

@@ -18,12 +18,12 @@ objectData:
{{- $rootCtx := .rootCtx -}}
{{- $objectData := .objectData -}}
{{- $pvcRetain := $rootCtx.Values.fallbackDefaults.pvcRetain -}}
{{- $pvcRetain := $rootCtx.Values.global.fallbackDefaults.pvcRetain -}}
{{- if (kindIs "bool" $objectData.retain) -}}
{{- $pvcRetain = $objectData.retain -}}
{{- end -}}
{{- $pvcSize := $rootCtx.Values.fallbackDefaults.pvcSize -}}
{{- $pvcSize := $rootCtx.Values.global.fallbackDefaults.pvcSize -}}
{{- with $objectData.size -}}
{{- $pvcSize = tpl . $rootCtx -}}
{{- end }}

View File

@@ -11,7 +11,7 @@ objectData: The service data, that will be used to render the Service object.
{{- $rootCtx := .rootCtx -}}
{{- $objectData := .objectData -}}
{{- $svcType := $objectData.type | default $rootCtx.Values.fallbackDefaults.serviceType -}}
{{- $svcType := $objectData.type | default $rootCtx.Values.global.fallbackDefaults.serviceType -}}
{{/* Init variables */}}
{{- $hasHTTPSPort := false -}}

View File

@@ -17,13 +17,13 @@
{{- $inProgress := false -}}
{{- $reusePVC := true -}}
{{- $preloadLibraries := list -}}
{{- $walSize := $rootCtx.Values.fallbackDefaults.vctSize -}}
{{- $size := $rootCtx.Values.fallbackDefaults.vctSize -}}
{{- $walSize := $rootCtx.Values.global.fallbackDefaults.vctSize -}}
{{- $size := $rootCtx.Values.global.fallbackDefaults.vctSize -}}
{{- $primaryUpdateStrategy := "unsupervised" -}}
{{- $primaryUpdateMethod := "switchover" -}}
{{- $logLevel := "info" -}}
{{- $accessModes := $rootCtx.Values.fallbackDefaults.vctAccessModes -}}
{{- $walAccessModes := $rootCtx.Values.fallbackDefaults.vctAccessModes -}}
{{- $accessModes := $rootCtx.Values.global.fallbackDefaults.vctAccessModes -}}
{{- $walAccessModes := $rootCtx.Values.global.fallbackDefaults.vctAccessModes -}}
{{/* Make sure keys exist before try to access any sub keys */}}
{{- if not (hasKey $objectData "cluster") -}}

View File

@@ -61,7 +61,7 @@ objectData: The object data to be used to render the container.
{{- end -}}
{{- $tcpProtocols := (list "tcp" "http" "https") -}}
{{- $protocol := tpl ($portValues.protocol | default $rootCtx.Values.fallbackDefaults.serviceProtocol) $rootCtx -}}
{{- $protocol := tpl ($portValues.protocol | default $rootCtx.Values.global.fallbackDefaults.serviceProtocol) $rootCtx -}}
{{- if mustHas $protocol $tcpProtocols -}}
{{- $protocol = "tcp" -}}
{{- end }}

View File

@@ -34,7 +34,7 @@ objectData: The object data to be used to render the container.
{{- if $isEnabled -}}
{{- $probeType := $rootCtx.Values.fallbackDefaults.probeType -}}
{{- $probeType := $rootCtx.Values.global.fallbackDefaults.probeType -}}
{{- with $probe.type -}}
{{- $probeType = tpl . $rootCtx -}}
@@ -71,7 +71,7 @@ objectData: The object data to be used to render the container.
{{- $objectData := .objectData -}}
{{- $probeName := .probeName -}}
{{- $timeouts := mustDeepCopy (get $rootCtx.Values.fallbackDefaults.probeTimeouts $probeName) -}}
{{- $timeouts := mustDeepCopy (get $rootCtx.Values.global.fallbackDefaults.probeTimeouts $probeName) -}}
{{- if $objectData.spec -}} {{/* Overwrite with defined timeouts */}}
{{- $timeouts = mustMergeOverwrite $timeouts $objectData.spec -}}

View File

@@ -12,7 +12,7 @@ objectData: The object data of the service
{{- $tcpProtocols := (list "tcp" "http" "https") -}}
{{- range $name, $portValues := $objectData.ports -}}
{{- if $portValues.enabled -}}
{{- $protocol := $rootCtx.Values.fallbackDefaults.serviceProtocol -}} {{/* Default to fallback protocol, if no protocol is defined */}}
{{- $protocol := $rootCtx.Values.global.fallbackDefaults.serviceProtocol -}} {{/* Default to fallback protocol, if no protocol is defined */}}
{{- $port := $portValues.targetPort | default $portValues.port -}}
{{/* Expand targetPort */}}

View File

@@ -12,7 +12,7 @@ objectData: The object data of the service
{{- $tcpProtocols := (list "tcp" "http" "https") -}}
{{- range $name, $portValues := $objectData.ports -}}
{{- if $portValues.enabled -}}
{{- $protocol := $rootCtx.Values.fallbackDefaults.serviceProtocol -}} {{/* Default to fallback protocol, if no protocol is defined */}}
{{- $protocol := $rootCtx.Values.global.fallbackDefaults.serviceProtocol -}} {{/* Default to fallback protocol, if no protocol is defined */}}
{{- $port := $portValues.targetPort | default $portValues.port -}}
{{/* Expand targetPort */}}

View File

@@ -49,7 +49,7 @@ objectData: The object data to be used to render the Pod.
{{/* If pod selected */}}
{{- if $selected -}}
{{/* Define the volume based on type */}}
{{- $type := ($persistence.type | default $rootCtx.Values.fallbackDefaults.persistenceType) -}}
{{- $type := ($persistence.type | default $rootCtx.Values.global.fallbackDefaults.persistenceType) -}}
{{- include "tc.v1.common.lib.pod.volumes.checkRWO" (dict
"rootCtx" $rootCtx "objectData" $objectData "persistence" $persistence

View File

@@ -12,7 +12,7 @@ objectData: The object data of the service
{{- $tcpProtocols := (list "tcp" "http" "https") -}}
{{- range $name, $portValues := $objectData.ports -}}
{{- if $portValues.enabled -}}
{{- $protocol := $rootCtx.Values.fallbackDefaults.serviceProtocol -}} {{/* Default to fallback protocol, if no protocol is defined */}}
{{- $protocol := $rootCtx.Values.global.fallbackDefaults.serviceProtocol -}} {{/* Default to fallback protocol, if no protocol is defined */}}
{{- $port := $portValues.port -}}
{{- $targetPort := $portValues.targetPort -}}
{{- $nodePort := $portValues.nodePort -}}

View File

@@ -17,7 +17,7 @@ objectData: The object data of the pvc
{{- end -}}
{{- if not $accessModes -}}
{{- $accessModes = $rootCtx.Values.fallbackDefaults.accessModes -}}
{{- $accessModes = $rootCtx.Values.global.fallbackDefaults.accessModes -}}
{{- end -}}
{{- $validAccessModes := (list "ReadWriteOnce" "ReadOnlyMany" "ReadWriteMany" "ReadWriteOncePod") -}}

View File

@@ -17,7 +17,7 @@ objectData: The object data of the pvc
Else if we are in an ixChartContext, always return the storageClassName defined on the ixChartContext
Else if there is a storageClass defined in Values.fallbackDefaults.storageClass, return this
Else if there is a storageClass defined in Values.global.fallbackDefaults.storageClass, return this
In any other case, return nothing
*/}}
@@ -43,9 +43,9 @@ objectData: The object data of the pvc
{{- end -}}
{{- $className = tpl $rootCtx.Values.global.ixChartContext.storageClassName $rootCtx -}}
{{- else if $rootCtx.Values.fallbackDefaults.storageClass -}}
{{- else if $rootCtx.Values.global.fallbackDefaults.storageClass -}}
{{- $className = tpl $rootCtx.Values.fallbackDefaults.storageClass $rootCtx -}}
{{- $className = tpl $rootCtx.Values.global.fallbackDefaults.storageClass $rootCtx -}}
{{- end -}}

View File

@@ -39,13 +39,13 @@ objectData: The object data to be used to render the Pod.
{{/* If pod selected */}}
{{- if $selected -}}
{{- $vctSize := $rootCtx.Values.fallbackDefaults.vctSize -}}
{{- $vctSize := $rootCtx.Values.global.fallbackDefaults.vctSize -}}
{{- with $vct.size -}}
{{- $vctSize = tpl . $rootCtx -}}
{{- end -}}
{{- $_ := set $vct "size" $vctSize -}}
{{- $vctAccessModes := $rootCtx.Values.fallbackDefaults.vctAccessModes -}}
{{- $vctAccessModes := $rootCtx.Values.global.fallbackDefaults.vctAccessModes -}}
{{- with $vct.accessModes -}}
{{- $vctAccessModes = . -}}
{{- end -}}

View File

@@ -19,7 +19,7 @@ objectData: The object data to be used to render the Pod.
{{- if $objectData.static -}}
{{- if and $objectData.static.mode (mustHas $objectData.static.mode $modes) -}}
{{- $size := $objectData.size | default $rootCtx.Values.fallbackDefaults.pvcSize -}}
{{- $size := $objectData.size | default $rootCtx.Values.global.fallbackDefaults.pvcSize -}}
{{/* Create a unique name taking into account server and share,
without this, changing one of those values is not possible */}}

View File

@@ -8,7 +8,7 @@ objectData: The object data to be used to render the Pod.
{{- $rootCtx := .rootCtx -}}
{{- $objectData := .objectData -}}
{{- $size := $rootCtx.Values.fallbackDefaults.pvcSize -}}
{{- $size := $rootCtx.Values.global.fallbackDefaults.pvcSize -}}
{{- with $objectData.size -}}
{{- $size = tpl . $rootCtx -}}
{{- end }}

View File

@@ -14,7 +14,7 @@
{{/* If autoPermissions is enabled...*/}}
{{- if $mount.autoPermissions.enabled -}}
{{- if or $mount.autoPermissions.chown $mount.autoPermissions.chmod -}}
{{- $type := $.Values.fallbackDefaults.persistenceType -}}
{{- $type := $.Values.global.fallbackDefaults.persistenceType -}}
{{- if $mount.type -}}
{{- $type = $mount.type -}}
{{- end -}}

View File

@@ -17,7 +17,7 @@
{{/* Create a copy of the persistence */}}
{{- $objectData := (mustDeepCopy $persistence) -}}
{{- $_ := set $objectData "type" ($objectData.type | default $.Values.fallbackDefaults.persistenceType) -}}
{{- $_ := set $objectData "type" ($objectData.type | default $.Values.global.fallbackDefaults.persistenceType) -}}
{{- include "tc.v1.common.lib.util.metaListToDict" (dict "objectData" $objectData) -}}

View File

@@ -8,6 +8,49 @@ global:
# TODO: Currently some objects do not support this
namespace: ""
fallbackDefaults:
# -- Define a storageClassName that will be used for all PVCs
# Can be overruled per PVC
storageClass:
# -- Default probe type
probeType: http
# -- Default Service Protocol
serviceProtocol: tcp
# -- Default Service Type
serviceType: ClusterIP
# -- Default persistence type
persistenceType: pvc
# -- Default Retain PVC
pvcRetain: false
# -- Default PVC Size
pvcSize: 100Gi
# -- Default VCT Size
vctSize: 100Gi
# -- Default PVC Access Modes
accessModes:
- ReadWriteOnce
# -- Default VCT Access Modes
vctAccessModes:
- ReadWriteOnce
# -- Default probe timeouts
probeTimeouts:
liveness:
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 5
successThreshold: 1
readiness:
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 5
successThreshold: 2
startup:
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 2
failureThreshold: 60
successThreshold: 1
# -- Define a postgresql version for CNPG
# will be used for all CNPG objects
# Can be overruled per CNPG objects
@@ -40,51 +83,6 @@ global:
# does not include stand-alone pods
stopAll: false
fallbackDefaults:
# -- Define a storageClassName that will be used for all PVCs
# Can be overruled per PVC
storageClass:
# -- Default probe type
probeType: http
# -- Default Service Protocol
serviceProtocol: tcp
# -- Default Service Type
serviceType: ClusterIP
# -- Default persistence type
persistenceType: pvc
# -- Default Retain PVC
pvcRetain: false
# -- Default PVC Size
pvcSize: 100Gi
# -- Default VCT Size
vctSize: 100Gi
# -- Default PVC Access Modes
accessModes:
- ReadWriteOnce
# -- Default VCT Access Modes
vctAccessModes:
- ReadWriteOnce
# -- Default probe timeouts
probeTimeouts:
liveness:
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 5
successThreshold: 1
readiness:
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 5
successThreshold: 2
startup:
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 2
failureThreshold: 60
successThreshold: 1
# -- Explicitly set a namespace for this chart only
namespace: ""