-
Notifications
You must be signed in to change notification settings - Fork 685
/
types.go
42 lines (32 loc) · 871 Bytes
/
types.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
package watt
import (
"encoding/json"
"time"
"github.com/datawire/ambassador/v2/pkg/consulwatch"
"github.com/datawire/ambassador/v2/pkg/k8s"
)
type ConsulSnapshot struct {
Endpoints map[string]consulwatch.Endpoints `json:",omitempty"`
}
func (s *ConsulSnapshot) DeepCopy() (*ConsulSnapshot, error) {
jsonBytes, err := json.Marshal(s)
if err != nil {
return nil, err
}
res := &ConsulSnapshot{}
err = json.Unmarshal(jsonBytes, res)
return res, err
}
type Error struct {
Source string
Message string
Timestamp int64
}
func NewError(source, message string) Error {
return Error{Source: source, Message: message, Timestamp: time.Now().Unix()}
}
type Snapshot struct {
Consul ConsulSnapshot `json:",omitempty"`
Kubernetes map[string][]k8s.Resource `json:",omitempty"`
Errors map[string][]Error `json:",omitempty"`
}