(path, key string)
| 366 | } |
| 367 | |
| 368 | func readFileByKeyAsUint64(path, key string) (uint64, error) { |
| 369 | content, err := ioutil.ReadFile(path) |
| 370 | if err != nil { |
| 371 | return 0, err |
| 372 | } |
| 373 | for _, line := range strings.Split(string(content), "\n") { |
| 374 | fields := strings.SplitN(line, " ", 2) |
| 375 | if fields[0] == key { |
| 376 | v := cleanString(string(fields[1])) |
| 377 | if v == "max" { |
| 378 | return math.MaxUint64, nil |
| 379 | } |
| 380 | ret, err := strconv.ParseUint(v, 10, 64) |
| 381 | if err != nil { |
| 382 | return ret, errors.Wrapf(err, "parse %s from %s", v, path) |
| 383 | } |
| 384 | return ret, nil |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | return 0, fmt.Errorf("no key named %s from %s", key, path) |
| 389 | } |
| 390 | |
| 391 | // New creates a new cgroup control |
| 392 | func New(path string, resources *spec.LinuxResources) (*CgroupControl, error) { |
no test coverage detected
searching dependent graphs…