func formatResource(resource *mesosproto.Resource) string { switch resource.GetType() { case mesosproto.Value_SCALAR: if resource.GetName() == "disk" || resource.GetName() == "mem" { return units.BytesSize(resource.GetScalar().GetValue() * 1024 * 1024) } return fmt.Sprintf("%d", int(resource.GetScalar().GetValue())) case mesosproto.Value_RANGES: var ranges []string for _, r := range resource.GetRanges().GetRange() { ranges = append(ranges, fmt.Sprintf("%d-%d", r.GetBegin(), r.GetEnd())) } return strings.Join(ranges, ", ") } return "?" }
// isScalar returns true if the given resource is a scalar type. func isScalar(r *mesos.Resource) bool { return r.GetType() == mesos.Value_SCALAR }