-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhistory.go
45 lines (43 loc) · 1.29 KB
/
history.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
package patrol
type History struct {
InstanceID string `json:"instance-id,omitempty"`
PID uint32 `json:"pid,omitempty"`
Started *Timestamp `json:"started,omitempty"`
LastSeen *Timestamp `json:"lastseen,omitempty"`
Stopped *Timestamp `json:"stopped,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Restart bool `json:"restart,omitempty"`
RunOnce bool `json:"run-once,omitempty"`
Shutdown bool `json:"shutdown,omitempty"`
ExitCode uint8 `json:"exit-code,omitempty"`
KeyValue map[string]interface{} `json:"keyvalue,omitempty"`
}
func (self *History) IsValid() bool {
if self == nil {
return false
}
return true
}
func (self *History) clone() *History {
if self == nil {
return nil
}
h := &History{
InstanceID: self.InstanceID,
PID: self.PID,
Started: self.Started,
LastSeen: self.LastSeen,
Stopped: self.Stopped,
Disabled: self.Disabled,
Restart: self.Restart,
RunOnce: self.RunOnce,
Shutdown: self.Shutdown,
ExitCode: self.ExitCode,
KeyValue: make(map[string]interface{}),
}
// dereference
for k, v := range self.KeyValue {
h.KeyValue[k] = v
}
return h
}