diff --git a/schema/types/isolator_resources.go b/schema/types/isolator_resources.go index d6d264a5..82f71904 100644 --- a/schema/types/isolator_resources.go +++ b/schema/types/isolator_resources.go @@ -128,6 +128,21 @@ func (r ResourceCPU) AssertValid() error { return nil } +func (r ResourceCPU) AsIsolator() Isolator { + isol := isolatorMap[ResourceCPUName]() + + b, err := json.Marshal(r.val) + if err != nil { + panic(err) + } + valRaw := json.RawMessage(b) + return Isolator{ + Name: ResourceCPUName, + ValueRaw: &valRaw, + value: isol, + } +} + func NewResourceCPUIsolator(request, limit string) (*ResourceCPU, error) { req, err := resource.ParseQuantity(request) if err != nil { @@ -167,6 +182,21 @@ func (r ResourceMemory) AssertValid() error { return nil } +func (r ResourceMemory) AsIsolator() Isolator { + isol := isolatorMap[ResourceMemoryName]() + + b, err := json.Marshal(r.val) + if err != nil { + panic(err) + } + valRaw := json.RawMessage(b) + return Isolator{ + Name: ResourceMemoryName, + ValueRaw: &valRaw, + value: isol, + } +} + func NewResourceMemoryIsolator(request, limit string) (*ResourceMemory, error) { req, err := resource.ParseQuantity(request) if err != nil {