Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional annotations to the extra configmap and secrets #30303

Merged
merged 3 commits into from
Apr 3, 2023
Merged
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
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 }}
sudeepgupta90 marked this conversation as resolved.
Show resolved Hide resolved
{{- 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 }}
sudeepgupta90 marked this conversation as resolved.
Show resolved Hide resolved
{{- 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