...
1 package consulwatch
2
3 import "time"
4
5
6
7 type Endpoints struct {
8 Id string `json:""`
9 Service string `json:""`
10 Endpoints []Endpoint `json:""`
11 }
12
13
14 func (e *Endpoints) GroupByTags() map[string][]Endpoint {
15 result := make(map[string][]Endpoint)
16
17 for _, endpoint := range e.Endpoints {
18 for _, tag := range endpoint.Tags {
19 if _, found := result[tag]; !found {
20 result[tag] = []Endpoint{}
21 }
22
23 updatedEndpoints := append(result[tag], endpoint)
24 result[tag] = updatedEndpoints
25 }
26 }
27
28 return result
29 }
30
31 type Endpoint struct {
32 SystemID string `json:""`
33 ID string `json:""`
34 Service string `json:""`
35 Address string `json:""`
36 Port int `json:""`
37 Tags []string `json:""`
38 }
39
40 type Certificate struct {
41 SerialNumber string `json:",omitempty"`
42 PEM string `json:",omitempty"`
43 PrivateKeyPEM string `json:",omitempty"`
44 Service string `json:",omitempty"`
45 ServiceURI string `json:",omitempty"`
46 ValidAfter time.Time `json:",omitempty"`
47 ValidBefore time.Time `json:",omitempty"`
48 }
49
50 type CARoot struct {
51 ID string `json:",omitempty"`
52 Name string `json:",omitempty"`
53 PEM string `json:",omitempty"`
54 Active bool
55 }
56
57 type CARoots struct {
58 ActiveRootID string
59 TrustDomain string
60 Roots map[string]CARoot
61 }
62
View as plain text