Skip to content

Commit

Permalink
Introduce schemav1#IcingaState
Browse files Browse the repository at this point in the history
  • Loading branch information
lippserd committed May 24, 2024
1 parent be1e77e commit e596843
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions pkg/schema/v1/icinga_state.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package v1

import (
"database/sql/driver"
"fmt"
)

type IcingaState uint8

const (
Ok IcingaState = iota
Warning
Critical
Unknown
Pending IcingaState = 99
)

func (s IcingaState) String() string {
switch s {
case Ok:
return "ok"
case Warning:
return "warning"
case Critical:
return "critical"
case Unknown:
return "unknown"
case Pending:
return "pending"
default:
panic(fmt.Sprintf("invalid Icinga state %d", s))
}
}

// Value implements the driver.Valuer interface.
func (s IcingaState) Value() (driver.Value, error) {
return s.String(), nil
}

// Assert interface compliance.
var (
_ fmt.Stringer = (*IcingaState)(nil)
_ driver.Valuer = (*IcingaState)(nil)
)

0 comments on commit e596843

Please sign in to comment.