File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ package v1
2
+
3
+ import (
4
+ "database/sql/driver"
5
+ "fmt"
6
+ )
7
+
8
+ type IcingaState uint8
9
+
10
+ const (
11
+ Ok IcingaState = iota
12
+ Warning
13
+ Critical
14
+ Unknown
15
+ Pending IcingaState = 99
16
+ )
17
+
18
+ func (s IcingaState ) String () string {
19
+ switch s {
20
+ case Ok :
21
+ return "ok"
22
+ case Warning :
23
+ return "warning"
24
+ case Critical :
25
+ return "critical"
26
+ case Unknown :
27
+ return "unknown"
28
+ case Pending :
29
+ return "pending"
30
+ default :
31
+ panic (fmt .Sprintf ("invalid Icinga state %d" , s ))
32
+ }
33
+ }
34
+
35
+ // Value implements the driver.Valuer interface.
36
+ func (s IcingaState ) Value () (driver.Value , error ) {
37
+ return s .String (), nil
38
+ }
39
+
40
+ // Assert interface compliance.
41
+ var (
42
+ _ fmt.Stringer = (* IcingaState )(nil )
43
+ _ driver.Valuer = (* IcingaState )(nil )
44
+ )
You can’t perform that action at this time.
0 commit comments