// GetNonzeroRequests returns the default resource request if none is found or what is provided on the request // TODO: Consider setting default as a fixed fraction of machine capacity (take "capacity v1.ResourceList" // as an additional argument here) rather than using constants func GetNonzeroRequests(requests *v1.ResourceList) (int64, int64) { var outMilliCPU, outMemory int64 // Override if un-set, but not if explicitly set to zero if _, found := (*requests)[v1.ResourceCPU]; !found { outMilliCPU = DefaultMilliCpuRequest } else { outMilliCPU = requests.Cpu().MilliValue() } // Override if un-set, but not if explicitly set to zero if _, found := (*requests)[v1.ResourceMemory]; !found { outMemory = DefaultMemoryRequest } else { outMemory = requests.Memory().Value() } return outMilliCPU, outMemory }