...
1
16
17 package v1
18
19 import (
20 "k8s.io/apimachinery/pkg/api/resource"
21 )
22
23
24 func (rn ResourceName) String() string {
25 return string(rn)
26 }
27
28
29 func (rl *ResourceList) Cpu() *resource.Quantity {
30 return rl.Name(ResourceCPU, resource.DecimalSI)
31 }
32
33
34 func (rl *ResourceList) Memory() *resource.Quantity {
35 return rl.Name(ResourceMemory, resource.BinarySI)
36 }
37
38
39 func (rl *ResourceList) Storage() *resource.Quantity {
40 return rl.Name(ResourceStorage, resource.BinarySI)
41 }
42
43
44 func (rl *ResourceList) Pods() *resource.Quantity {
45 return rl.Name(ResourcePods, resource.DecimalSI)
46 }
47
48
49 func (rl *ResourceList) StorageEphemeral() *resource.Quantity {
50 return rl.Name(ResourceEphemeralStorage, resource.BinarySI)
51 }
52
53
54 func (rl *ResourceList) Name(name ResourceName, defaultFormat resource.Format) *resource.Quantity {
55 if val, ok := (*rl)[name]; ok {
56 return &val
57 }
58 return &resource.Quantity{Format: defaultFormat}
59 }
60
View as plain text