forked from derailed/k9s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell_pod.go
44 lines (37 loc) · 933 Bytes
/
shell_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
package config
import (
"github.com/derailed/k9s/internal/client"
v1 "k8s.io/api/core/v1"
)
const defaultDockerShellImage = "busybox:1.31"
// Limits represents resource limits.
type Limits map[v1.ResourceName]string
// ShellPod represents k9s shell configuration.
type ShellPod struct {
Image string `json:"Image"`
Namespace string `json:"namespace"`
Limits Limits `json:"resources,omitempty"`
}
// NewShellPod returns a new instance.
func NewShellPod() *ShellPod {
return &ShellPod{
Image: defaultDockerShellImage,
Namespace: "default",
Limits: defaultLimits(),
}
}
// Validate validates the configuration.
func (s *ShellPod) Validate(client.Connection, KubeSettings) {
if s.Image == "" {
s.Image = defaultDockerShellImage
}
if len(s.Limits) == 0 {
s.Limits = defaultLimits()
}
}
func defaultLimits() Limits {
return Limits{
v1.ResourceCPU: "100m",
v1.ResourceMemory: "100Mi",
}
}