/
types.go
45 lines (36 loc) · 1.07 KB
/
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
43
44
45
package sources
import (
"time"
cadvisor "github.com/google/cadvisor/info/v1"
)
type Container struct {
Name string `json:"name,omitempty"`
Spec cadvisor.ContainerSpec `json:"spec,omitempty"`
Stats []*cadvisor.ContainerStats `json:"stats,omitempty"`
}
func newContainer() *Container {
return &Container{Stats: make([]*cadvisor.ContainerStats, 0)}
}
type RawContainer struct {
Hostname string `json:"hostname,omitempty"`
Container
}
type ContainerData struct {
Containers []RawContainer
Machine []RawContainer
}
type CadvisorHosts struct {
Port int `json:"port"`
Hosts map[string]string `json:"hosts"`
}
type Source interface {
// Fetches containers information from all the nodes in the cluster.
// Returns:
// 1. podsOrContainers: A slice of Pod or a slice of RawContainer
// 2. nodes: A slice of RawContainer, one for each node in the cluster, that contains
// root cgroup information.
GetInfo() (ContainerData, error)
}
func NewSource(pollDuration time.Duration) (Source, error) {
return newExternalSource(pollDuration)
}