From 5cde203e0b1f231ab047bbcaa907a690c3143bee Mon Sep 17 00:00:00 2001 From: Jason Wells Date: Tue, 25 Jul 2023 15:31:47 -0700 Subject: [PATCH] fix tests and do not attempt to retrieve update_in_comment from defaults Signed-off-by: Jason Wells --- examples/jiralert.yml | 6 +++--- pkg/config/config.go | 3 --- pkg/config/config_test.go | 5 ++--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/examples/jiralert.yml b/examples/jiralert.yml index 21ee72c..8776a71 100644 --- a/examples/jiralert.yml +++ b/examples/jiralert.yml @@ -34,8 +34,6 @@ receivers: project: AB # Copy all Prometheus labels into separate JIRA labels. Optional (default: false). add_group_labels: false - # Include ticket update as comment too. Optional (default: false). - update_in_comment: false # Will be merged with the static_labels from the default map static_labels: ["anotherLabel"] @@ -58,7 +56,9 @@ receivers: # # Automatically resolve jira issues when alert is resolved. Optional. If declared, ensure state is not an empty string. auto_resolve: - state: 'Done' + state: 'Done' + # Include ticket update as comment. Optional (default: false). + update_in_comment: false # File containing template definitions. Required. template: jiralert.tmpl diff --git a/pkg/config/config.go b/pkg/config/config.go index 07ea712..2b8dd99 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -314,9 +314,6 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { if len(c.Defaults.StaticLabels) > 0 { rc.StaticLabels = append(rc.StaticLabels, c.Defaults.StaticLabels...) } - if ! rc.UpdateInComment { - rc.UpdateInComment = c.Defaults.UpdateInComment - } } if len(c.Receivers) == 0 { diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index e370aa6..222e148 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -333,10 +333,11 @@ func TestReceiverOverrides(t *testing.T) { {"WontFixResolution", "Won't Fix", "Won't Fix"}, {"AddGroupLabels", false, false}, {"UpdateInComment", false, false}, + {"UpdateInComment", true, true}, {"AutoResolve", &AutoResolve{State: "Done"}, &autoResolve}, {"StaticLabels", []string{"somelabel"}, []string{"somelabel"}}, } { - optionalFields := []string{"Priority", "Description", "WontFixResolution", "AddGroupLabels", "UpdateInComment", "AutoResolve", "StaticLabels"} + optionalFields := []string{"Priority", "Description", "WontFixResolution", "AddGroupLabels", "AutoResolve", "StaticLabels"} defaultsConfig := newReceiverTestConfig(mandatoryReceiverFields(), optionalFields) receiverConfig := newReceiverTestConfig([]string{"Name"}, optionalFields) @@ -388,8 +389,6 @@ func newReceiverTestConfig(mandatory []string, optional []string) *receiverTestC var value reflect.Value if name == "AddGroupLabels" { value = reflect.ValueOf(true) - } else if name == "UpdateInComment" { - value = reflect.ValueOf(true) } else if name == "AutoResolve" { value = reflect.ValueOf(&AutoResolve{State: "Done"}) } else if name == "StaticLabels" {