func deepCopy_v1_ResourceRequirements(in v1.ResourceRequirements, out *v1.ResourceRequirements, c *conversion.Cloner) error { if in.Limits != nil { out.Limits = make(v1.ResourceList) for key, val := range in.Limits { newVal := new(resource.Quantity) if err := deepCopy_resource_Quantity(val, newVal, c); err != nil { return err } out.Limits[key] = *newVal } } else { out.Limits = nil } if in.Requests != nil { out.Requests = make(v1.ResourceList) for key, val := range in.Requests { newVal := new(resource.Quantity) if err := deepCopy_resource_Quantity(val, newVal, c); err != nil { return err } out.Requests[key] = *newVal } } else { out.Requests = nil } return nil }
// HandleResourceRequirements parses the limits and requests parameters if specified func handleV1ResourceRequirements(params map[string]string) (v1.ResourceRequirements, error) { result := v1.ResourceRequirements{} limits, err := populateV1ResourceList(params["limits"]) if err != nil { return result, err } result.Limits = limits requests, err := populateV1ResourceList(params["requests"]) if err != nil { return result, err } result.Requests = requests return result, nil }
func getPod(cpuLimit, memoryLimit string) *v1.Pod { resources := v1.ResourceRequirements{} if cpuLimit != "" || memoryLimit != "" { resources.Limits = make(v1.ResourceList) } if cpuLimit != "" { resources.Limits[v1.ResourceCPU] = resource.MustParse(cpuLimit) } if memoryLimit != "" { resources.Limits[v1.ResourceMemory] = resource.MustParse(memoryLimit) } return &v1.Pod{ Spec: v1.PodSpec{ Containers: []v1.Container{ { Name: "foo", Resources: resources, }, }, }, } }
func getResourceRequirements(requests, limits v1.ResourceList) v1.ResourceRequirements { res := v1.ResourceRequirements{} res.Requests = requests res.Limits = limits return res }