Skip to content

Commit

Permalink
Add additional annotations to the extra configmap and secrets (apache…
Browse files Browse the repository at this point in the history
  • Loading branch information
sudeepgupta90 authored Apr 3, 2023
1 parent 8bf4f62 commit 82c5a5f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
3 changes: 3 additions & 0 deletions chart/templates/configmaps/extra-configmaps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ metadata:
"helm.sh/hook": "pre-install,pre-upgrade"
"helm.sh/hook-delete-policy": "before-hook-creation"
"helm.sh/hook-weight": "0"
{{- if $configMapContent.annotations }}
{{- toYaml $configMapContent.annotations | nindent 4 }}
{{- end }}
{{- if $configMapContent.data }}
data:
{{- with $configMapContent.data }}
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/secrets/extra-secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ metadata:
"helm.sh/hook": "pre-install,pre-upgrade"
"helm.sh/hook-delete-policy": "before-hook-creation"
"helm.sh/hook-weight": "0"
{{- if $secretContent.annotations }}
{{- toYaml $secretContent.annotations | nindent 4 }}
{{- end }}
{{- if $secretContent.type }}
type: {{ $secretContent.type }}
{{- end }}
Expand Down
16 changes: 16 additions & 0 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,14 @@
"type": "string"
}
},
"annotations": {
"description": "Annotations for the secret",
"type": "object",
"default": null,
"additionalProperties": {
"type": "string"
}
},
"data": {
"description": "Content **as string** for the 'data' item of the secret (can be templated)",
"type": "string"
Expand Down Expand Up @@ -929,6 +937,14 @@
"type": "string"
}
},
"annotations": {
"description": "Annotations for the configmap",
"type": "object",
"default": null,
"additionalProperties": {
"type": "string"
}
},
"data": {
"description": "Content **as string** for the 'data' item of the configmap (can be templated)",
"type": "string"
Expand Down
2 changes: 1 addition & 1 deletion chart/values_schema.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"not": {
"properties": {
"description": {
"pattern": "^Labels for the configmap$|^Labels for the secret$"
"pattern": "^Labels for the configmap$|^Labels for the secret$|^Annotations for the configmap$|^Annotations for the secret$"
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions tests/charts/test_extra_configmaps_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,33 @@ def test_extra_configmaps_secrets_additional_labels(self, chart_labels, local_la
}
for k8s_object in k8s_objects:
assert k8s_object["metadata"]["labels"] == {**common_labels, **chart_labels, **local_labels}

def test_extra_configmaps_secrets_additional_annotations(self):
k8s_objects = render_chart(
name=RELEASE_NAME,
values={
"extraSecrets": {
"{{ .Release.Name }}-extra-secret-1": {
"annotations": {"test_annotation": "test_annotation_value"},
"stringData": "data: secretData",
}
},
"extraConfigMaps": {
"{{ .Release.Name }}-extra-configmap-1": {
"annotations": {"test_annotation": "test_annotation_value"},
"data": "data: configData",
}
},
},
show_only=["templates/configmaps/extra-configmaps.yaml", "templates/secrets/extra-secrets.yaml"],
)

expected_annotations = {
"helm.sh/hook": "pre-install,pre-upgrade",
"helm.sh/hook-delete-policy": "before-hook-creation",
"helm.sh/hook-weight": "0",
"test_annotation": "test_annotation_value",
}

for k8s_object in k8s_objects:
assert k8s_object["metadata"]["annotations"] == expected_annotations

0 comments on commit 82c5a5f

Please sign in to comment.