Skip to content

Commit

Permalink
refactor default alert method detection
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya committed Oct 28, 2020
1 parent f3ab714 commit a2ff8e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (c *ConfigFile) FillDefaults() error {
c.Projects[i] = p
}

if len(c.Alerts) == 0 {
if c.Alerts == nil {
var alert AlertConfigs
alert.Name = "log"
alert.Type = "log"
Expand Down
8 changes: 6 additions & 2 deletions projects/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,16 @@ func (p *Project) GetCritChannel() *alerts.AlertConfigs {
}

func (p *Project) GetProjectChannel() *alerts.AlertConfigs {
var alert alerts.AlertConfigs
for _, a := range config.Config.Alerts {
if a.Name == p.Parameters.AlertChannel {
return &alerts.AlertConfigs{a}
alert = alerts.AlertConfigs{a}
break
}
alert = alerts.AlertConfigs{config.AlertConfigs{Name: "log", Type: "log"}}
}
return nil

return &alert
}

func (p *Project) Send(text string) {
Expand Down

0 comments on commit a2ff8e8

Please sign in to comment.