-
Notifications
You must be signed in to change notification settings - Fork 5
/
pod.go
48 lines (44 loc) · 941 Bytes
/
pod.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
package pod
import (
"fmt"
"time"
"github.com/containerum/chkit/pkg/model"
kubeModel "github.com/containerum/kube-client/pkg/model"
)
type Pod struct {
Name string
Hostname string
Containers []string
Status Status
CreatedAt time.Time
origin kubeModel.Pod
}
func PodFromKube(pod kubeModel.Pod) Pod {
var containers []string
for _, container := range pod.Containers {
containers = append(containers,
fmt.Sprintf("%s [%s]",
container.Name,
container.Image))
}
hostname := ""
if pod.Hostname != nil {
hostname = *pod.Hostname
}
var status Status
if pod.Status != nil {
status = StatusFromKube(*pod.Status)
}
var createdAt time.Time
if pod.CreatedAt != nil {
createdAt, _ = time.Parse(model.TimestampFormat, *pod.CreatedAt)
}
return Pod{
Name: pod.Name,
Hostname: hostname,
Containers: containers,
Status: status,
CreatedAt: createdAt,
origin: pod,
}
}