Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions charts/sourcebot/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if and .Values.sourcebot.persistence.enabled (not .Values.sourcebot.persistence.existingClaim) }}
{{- $volumeName := printf "%s-%s" (include "sourcebot.fullname" .) "data" -}}
---
apiVersion: v1
kind: PersistentVolumeClaim
Expand All @@ -7,10 +8,11 @@ metadata:
namespace: {{ $.Release.Namespace }}
labels:
{{- include "sourcebot.labels" . | nindent 4 }}
{{- with .Values.sourcebot.persistence.annotations }}
annotations:
helm.sh/resource-policy: keep
{{- with .Values.sourcebot.persistence.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
spec:
accessModes:
{{- range .Values.sourcebot.persistence.accessModes }}
Expand All @@ -25,6 +27,9 @@ spec:
{{- else }}
storageClassName: {{ .Values.sourcebot.persistence.storageClass }}
{{- end }}
{{- if (lookup "v1" "PersistentVolumeClaim" $.Release.Namespace $volumeName) }}
volumeName: {{ (lookup "v1" "PersistentVolumeClaim" $.Release.Namespace $volumeName).spec.volumeName }}
{{- end }}
{{- end }}
{{- end }}

25 changes: 25 additions & 0 deletions charts/sourcebot/tests/basic_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,31 @@ tests:
claimName: my-existing-pvc
template: deployment.yaml

- it: should always have keep resource policy annotation on PVC
values:
- ../values.lint.yaml
asserts:
- equal:
path: metadata.annotations["helm.sh/resource-policy"]
value: keep
template: pvc.yaml

- it: should merge custom annotations with helm resource policy on PVC
values:
- ../values.lint.yaml
set:
sourcebot.persistence.annotations:
custom.io/annotation: "my-value"
asserts:
- equal:
path: metadata.annotations["helm.sh/resource-policy"]
value: keep
template: pvc.yaml
- equal:
path: metadata.annotations["custom.io/annotation"]
value: my-value
template: pvc.yaml

- it: should set service type correctly
values:
- ../values.lint.yaml
Expand Down