Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Damien Duportal <[email protected]>
  • Loading branch information
dduportal committed Oct 5, 2023
1 parent a6314ad commit 414c0f1
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 2 deletions.
3 changes: 2 additions & 1 deletion charts/rsyncd/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ Expected argument: dict{
*/}}
{{- define "rsync.datadir-volumedef" -}}
{{- if .currentRsyncComponent.volumeTpl -}}
{{- printf "%s" (tpl .currentRsyncComponent.volumeTpl .rootContext) | trim | trunc 63 }}
persistentVolumeClaim:
claimName: {{ printf "%s" (tpl .currentRsyncComponent.volumeTpl .rootContext) | trim | trunc 63 -}}
{{- else if .currentRsyncComponent.volume -}}
{{- toYaml .currentRsyncComponent.volume -}}
{{- else -}}
Expand Down
2 changes: 1 addition & 1 deletion charts/rsyncd/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ spec:
sizeLimit: 32Mi
{{- range .Values.configuration.components }}
- name: datadir-{{ .name }}
{{- include "rsync.datadir-volumedef" (dict "currentRsyncComponent" . "rootContext" .) | nindent 10 }}
{{- include "rsync.datadir-volumedef" (dict "currentRsyncComponent" . "rootContext" $) | nindent 10 }}
{{- end }}
147 changes: 147 additions & 0 deletions charts/rsyncd/tests/parent_values_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
suite: Tests with parent values
# Custom values used to test all suites from this file
set:
global:
storage:
enabled: true
configuration:
components:
- name: jenkins
path: /rsyncd/data/jenkins
comment: "Jenkins Read-Only Mirror"
volumeTpl: '{{ default "parent-chart-shared-data" }}'
- name: hudson
path: /tmp/hudson
comment: "Hudson Read-Only Mirror"
volume:
persistentVolumeClaim:
claimName: another-vol
tests:
- it: should define a customized "rsyncd" deployment
template: deployment.yaml
asserts:
- hasDocuments:
count: 1
- isKind:
of: Deployment
# Custom rsyncd.inc configuration overlay is mounted from the rsyncd-conf configmap
- equal:
path: spec.template.spec.volumes[0].name
value: rsyncd-conf
- equal:
path: spec.template.spec.volumes[0].configMap.name
value: RELEASE-NAME-rsyncd-conf
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].name
value: rsyncd-conf
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].subPath
value: rsyncd.inc
- equal:
path: spec.template.spec.containers[0].volumeMounts[0].mountPath
value: /etc/rsyncd.d/rsyncd.inc
# TempFS volumes
- equal:
path: spec.template.spec.volumes[1].name
value: ramfs
- equal:
path: spec.template.spec.volumes[1].emptyDir.medium
value: Memory
- equal:
path: spec.template.spec.containers[0].volumeMounts[2].name
value: ramfs
- equal:
path: spec.template.spec.containers[0].volumeMounts[2].mountPath
value: /tmp
- equal:
path: spec.template.spec.containers[0].volumeMounts[2].subPath
value: tmp
- equal:
path: spec.template.spec.containers[0].volumeMounts[3].name
value: ramfs
- equal:
path: spec.template.spec.containers[0].volumeMounts[3].mountPath
value: /rsync/run
- equal:
path: spec.template.spec.containers[0].volumeMounts[3].subPath
value: run
# Custom Rsyncd components
## jenkins (1 configmap volume mount + 1 data volume and 1 volumemount for data dir)
- equal:
path: spec.template.spec.volumes[2].name
value: datadir-jenkins
- equal:
path: spec.template.spec.volumes[2].persistentVolumeClaim.claimName
value: parent-chart-shared-data
- equal:
path: spec.template.spec.containers[0].volumeMounts[4].name
value: rsyncd-conf
- equal:
path: spec.template.spec.containers[0].volumeMounts[4].mountPath
value: /etc/rsyncd.d/jenkins.conf
- equal:
path: spec.template.spec.containers[0].volumeMounts[4].subPath
value: jenkins.conf
- equal:
path: spec.template.spec.containers[0].volumeMounts[4].readOnly
value: true
- equal:
path: spec.template.spec.containers[0].volumeMounts[5].name
value: datadir-jenkins
- equal:
path: spec.template.spec.containers[0].volumeMounts[5].mountPath
value: /rsyncd/data/jenkins
- notExists:
path: spec.template.spec.containers[0].volumeMounts[5].subPath
- equal:
path: spec.template.spec.containers[0].volumeMounts[5].readOnly
value: true
## hudson (1 configmap volume mount + 1 data volume and 1 volumemount for data dir)
- equal:
path: spec.template.spec.volumes[3].name
value: datadir-hudson
- equal:
path: spec.template.spec.volumes[3].persistentVolumeClaim.claimName
value: another-vol
- equal:
path: spec.template.spec.containers[0].volumeMounts[6].name
value: rsyncd-conf
- equal:
path: spec.template.spec.containers[0].volumeMounts[6].mountPath
value: /etc/rsyncd.d/hudson.conf
- equal:
path: spec.template.spec.containers[0].volumeMounts[6].subPath
value: hudson.conf
- equal:
path: spec.template.spec.containers[0].volumeMounts[6].readOnly
value: true
- equal:
path: spec.template.spec.containers[0].volumeMounts[7].name
value: datadir-hudson
- equal:
path: spec.template.spec.containers[0].volumeMounts[7].mountPath
value: /tmp/hudson
- notExists:
path: spec.template.spec.containers[0].volumeMounts[7].subPath
- equal:
path: spec.template.spec.containers[0].volumeMounts[7].readOnly
value: true
- it: should create a custom rsyncd-conf config map
template: configmap.rsyncd-conf.yaml
asserts:
- hasDocuments:
count: 1
- isKind:
of: ConfigMap
- equal:
path: metadata.name
value: RELEASE-NAME-rsyncd-conf
- matchRegex:
path: data["jenkins.conf"]
pattern: "[jenkins]"
- matchRegex:
path: data["hudson.conf"]
pattern: "[hudson]"
- matchRegex:
path: data["hudson.conf"]
pattern: "path = /tmp/hudson"

0 comments on commit 414c0f1

Please sign in to comment.