-
Notifications
You must be signed in to change notification settings - Fork 290
/
state.go
47 lines (39 loc) · 909 Bytes
/
state.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package dockercompose
// Three hacky states just for now to get something into the hud.
const (
StatusDown = "down"
StatusInProg = "in progress"
StatusUp = "up"
)
var containerActionToStatus = map[Action]string{
ActionCreate: StatusInProg,
ActionDie: StatusDown,
ActionKill: StatusDown,
ActionRename: StatusInProg,
ActionRestart: StatusUp, // ??
ActionStart: StatusUp,
ActionStop: StatusDown,
ActionUpdate: StatusUp, // ??
}
func (evt Event) GuessStatus() string {
if evt.Type != TypeContainer {
return ""
}
return containerActionToStatus[evt.Action]
}
type State struct {
Status string
CurrentLog []byte
}
func (State) ResourceState() {}
func (s State) Log() string {
return string(s.CurrentLog)
}
func (s State) WithCurrentLog(b []byte) State {
s.CurrentLog = b
return s
}
func (s State) WithStatus(status string) State {
s.Status = status
return s
}