-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.go
56 lines (51 loc) · 1.59 KB
/
config.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
package healthcheck
const (
// SourceConfig the check is managed by the configuration file
SourceConfig string = ""
// SourceAPI the check is managed by the API
SourceAPI string = "api"
// SourceHTTPDiscovery the check was created from the http discovery mechanism
SourceHTTPDiscovery string = "http-discovery"
)
// Base shared fields between healthchecks
type Base struct {
Name string `json:"name"`
Description string `json:"description"`
Interval Duration `json:"interval"`
OneOff bool `json:"one-off"`
Source string `json:"source"`
Labels map[string]string `json:"labels,omitempty"`
}
// SourceChecksNames returns all checks managed by the given source
func (c *Component) SourceChecksNames(source string) map[string]bool {
c.lock.Lock()
defer c.lock.Unlock()
checks := make(map[string]bool)
for i := range c.Healthchecks {
wrapper := c.Healthchecks[i]
if wrapper.healthcheck.Base().Source == source {
checks[wrapper.healthcheck.Base().Name] = true
}
}
return checks
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Base) DeepCopyInto(out *Base) {
*out = *in
if in.Labels != nil {
in, out := &in.Labels, &out.Labels
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Base.
func (in *Base) DeepCopy() *Base {
if in == nil {
return nil
}
out := new(Base)
in.DeepCopyInto(out)
return out
}