Skip to content

Commit

Permalink
fix tests and do not attempt to retrieve update_in_comment from defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
twotired committed Jul 25, 2023
1 parent 8227fb9 commit 60a58d4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
6 changes: 3 additions & 3 deletions examples/jiralert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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
3 changes: 0 additions & 3 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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" {
Expand Down

0 comments on commit 60a58d4

Please sign in to comment.