Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 8 additions & 2 deletions charts/sourcebot/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{- if and .Values.sourcebot.persistence.enabled (not .Values.sourcebot.persistence.existingClaim) }}
{{- $pvcName := printf "%s-%s" (include "sourcebot.fullname" .) "data" -}}
{{- $existingPvc := (lookup "v1" "PersistentVolumeClaim" $.Release.Namespace $pvcName) -}}
---
apiVersion: v1
kind: PersistentVolumeClaim
Expand All @@ -7,10 +9,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 @@ -26,5 +29,8 @@ spec:
storageClassName: {{ .Values.sourcebot.persistence.storageClass }}
{{- end }}
{{- end }}
{{- if and $existingPvc $existingPvc.spec.volumeName }}
volumeName: {{ $existingPvc.spec.volumeName }}
{{- 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