forked from hashicorp/consul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_definition.go
76 lines (69 loc) · 1.9 KB
/
check_definition.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package structs
import (
"time"
"github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/types"
)
// CheckDefinition is used to JSON decode the Check definitions
type CheckDefinition struct {
ID types.CheckID
Name string
Notes string
ServiceID string
Token string
Status string
// Copied fields from CheckType without the fields
// already present in CheckDefinition:
//
// ID (CheckID), Name, Status, Notes
//
Script string
HTTP string
Header map[string][]string
Method string
TCP string
Interval time.Duration
DockerContainerID string
Shell string
TLSSkipVerify bool
Timeout time.Duration
TTL time.Duration
DeregisterCriticalServiceAfter time.Duration
}
func (c *CheckDefinition) HealthCheck(node string) *HealthCheck {
health := &HealthCheck{
Node: node,
CheckID: c.ID,
Name: c.Name,
Status: api.HealthCritical,
Notes: c.Notes,
ServiceID: c.ServiceID,
}
if c.Status != "" {
health.Status = c.Status
}
if health.CheckID == "" && health.Name != "" {
health.CheckID = types.CheckID(health.Name)
}
return health
}
func (c *CheckDefinition) CheckType() *CheckType {
return &CheckType{
CheckID: c.ID,
Name: c.Name,
Status: c.Status,
Notes: c.Notes,
Script: c.Script,
HTTP: c.HTTP,
Header: c.Header,
Method: c.Method,
TCP: c.TCP,
Interval: c.Interval,
DockerContainerID: c.DockerContainerID,
Shell: c.Shell,
TLSSkipVerify: c.TLSSkipVerify,
Timeout: c.Timeout,
TTL: c.TTL,
DeregisterCriticalServiceAfter: c.DeregisterCriticalServiceAfter,
}
}