diff --git a/pkg/apis/core/resource.go b/pkg/apis/core/resource.go index fe199d3fa0c..d5006e5c8aa 100644 --- a/pkg/apis/core/resource.go +++ b/pkg/apis/core/resource.go @@ -40,6 +40,14 @@ func (rl *ResourceList) Memory() *resource.Quantity { return &resource.Quantity{Format: resource.BinarySI} } +// Storage returns the Storage limit if specified. +func (rl *ResourceList) Storage() *resource.Quantity { + if val, ok := (*rl)[ResourceStorage]; ok { + return &val + } + return &resource.Quantity{Format: resource.BinarySI} +} + // Pods returns the list of pods func (rl *ResourceList) Pods() *resource.Quantity { if val, ok := (*rl)[ResourcePods]; ok { diff --git a/staging/src/k8s.io/api/core/v1/resource.go b/staging/src/k8s.io/api/core/v1/resource.go index bb804125462..5bc9cd5bf1b 100644 --- a/staging/src/k8s.io/api/core/v1/resource.go +++ b/staging/src/k8s.io/api/core/v1/resource.go @@ -41,6 +41,14 @@ func (self *ResourceList) Memory() *resource.Quantity { return &resource.Quantity{Format: resource.BinarySI} } +// Returns the Storage limit if specified. +func (self *ResourceList) Storage() *resource.Quantity { + if val, ok := (*self)[ResourceStorage]; ok { + return &val + } + return &resource.Quantity{Format: resource.BinarySI} +} + func (self *ResourceList) Pods() *resource.Quantity { if val, ok := (*self)[ResourcePods]; ok { return &val