Skip to content

Commit

Permalink
allow annotations on helm dag pvc (#22261)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: a6fe387327f8901fbd23293352a3460c8b9047cf
  • Loading branch information
ajbosco authored and Cloud Composer Team committed Sep 12, 2024
1 parent 5821961 commit f40657b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
4 changes: 4 additions & 0 deletions chart/templates/dags-persistent-volume-claim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ metadata:
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- if .Values.dags.persistence.annotations}}
{{- toYaml .Values.dags.persistence.annotations | nindent 4 }}
{{- end }}
spec:
accessModes: [{{ .Values.dags.persistence.accessMode | quote }}]
resources:
Expand Down
8 changes: 8 additions & 0 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4202,6 +4202,14 @@
],
"default": null
},
"annotations": {
"description": "Annotations for the dag PVC",
"type": "object",
"default": {},
"additionalProperties": {
"type": "string"
}
},
"subPath": {
"description": "Subpath within the PVC where dags are located.",
"type": [
Expand Down
41 changes: 41 additions & 0 deletions tests/charts/test_dags_persistent_volume_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,44 @@ def test_should_set_pvc_details_correctly(self):
"resources": {"requests": {"storage": "1G"}},
"storageClassName": "MyStorageClass",
} == jmespath.search("spec", docs[0])

def test_single_annotation(self):
docs = render_chart(
values={
"dags": {
"persistence": {
"enabled": True,
"size": "1G",
"existingClaim": None,
"storageClassName": "MyStorageClass",
"accessMode": "ReadWriteMany",
"annotations": {"key": "value"},
}
}
},
show_only=["templates/dags-persistent-volume-claim.yaml"],
)

annotations = jmespath.search("metadata.annotations", docs[0])
assert "value" == annotations.get("key")

def test_multiple_annotations(self):
docs = render_chart(
values={
"dags": {
"persistence": {
"enabled": True,
"size": "1G",
"existingClaim": None,
"storageClassName": "MyStorageClass",
"accessMode": "ReadWriteMany",
"annotations": {"key": "value", "key-two": "value-two"},
}
}
},
show_only=["templates/dags-persistent-volume-claim.yaml"],
)

annotations = jmespath.search("metadata.annotations", docs[0])
assert "value" == annotations.get("key")
assert "value-two" == annotations.get("key-two")

0 comments on commit f40657b

Please sign in to comment.