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

Implement Stringer interface for Pairs and KVs #3256

Merged

Conversation

grobinson-grafana
Copy link
Contributor

This commit implements the Stringer interface for Pairs and KVs. It changes how Pairs are printed in templates from map[name1:value1 name2:value2] to name1=value1, name2=value2. KVs work similar, but are first sorted into pairs before being printed.

This should mean that Alertmanager has better text when using {{ .Annotations }} and {{ .Labels }}, as an example, without having to write a range with custom delimitation.

This commit implements the Stringer interface for Pairs and KVs.
It changes how Pairs are printed in templates from
map[name1:value1 name2:value2] to name1=value1, name2=value2. KVs
work similar, but are first sorted into pairs before being printed.

Signed-off-by: George Robinson <george.robinson@grafana.com>
@grobinson-grafana grobinson-grafana force-pushed the stringer-for-pairs-and-kvs branch from 5489eb7 to 81d78f3 Compare February 16, 2023 16:51
Copy link
Member

@gotjosh gotjosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gotjosh gotjosh merged commit 11d0b57 into prometheus:main Feb 22, 2023
hoperays pushed a commit to hoperays/alertmanager that referenced this pull request Apr 23, 2023
This commit implements the Stringer interface for Pairs and KVs.
It changes how Pairs are printed in templates from
map[name1:value1 name2:value2] to name1=value1, name2=value2. KVs
work similar, but are first sorted into pairs before being printed.

Signed-off-by: George Robinson <george.robinson@grafana.com>
radek-ryckowski pushed a commit to goldmansachs/alertmanager that referenced this pull request Nov 6, 2023
This commit implements the Stringer interface for Pairs and KVs.
It changes how Pairs are printed in templates from
map[name1:value1 name2:value2] to name1=value1, name2=value2. KVs
work similar, but are first sorted into pairs before being printed.

Signed-off-by: George Robinson <george.robinson@grafana.com>
@grobinson-grafana grobinson-grafana deleted the stringer-for-pairs-and-kvs branch April 16, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants