Skip to content

Commit

Permalink
Implemented Issue olorin#16: Status should be initialized as UNKNOWN …
Browse files Browse the repository at this point in the history
…instead of OK
  • Loading branch information
stevemeier committed Apr 5, 2021
1 parent 893f970 commit 4b57147
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion check.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type CheckOptions struct {
// NewCheck returns an empty Check object.
func NewCheck() *Check {
c := new(Check)
c.status = 3 // initialize as UNKNOWN, 0 (default) is OK
c.statusPolicy = NewDefaultStatusPolicy()
return c
}
Expand All @@ -71,7 +72,8 @@ func (c *Check) AddResult(status Status, message string) {
result.message = message
c.results = append(c.results, result)

if (*c.statusPolicy)[result.status] > (*c.statusPolicy)[c.status] {
if (*c.statusPolicy)[result.status] > (*c.statusPolicy)[c.status] ||
c.status == 3 { // allow trasition from UNKNOWN state to any
c.status = result.status
}
}
Expand Down

0 comments on commit 4b57147

Please sign in to comment.