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