| 429 | |
| 430 | if (devicesArray.isSome()) { |
| 431 | foreach (const JSON::Value& entry, devicesArray->values) { |
| 432 | if (!entry.is<JSON::Object>()) { |
| 433 | return Error("Malformed HostConfig.Devices" |
| 434 | " entry '" + stringify(entry) + "'"); |
| 435 | } |
| 436 | |
| 437 | JSON::Object object = entry.as<JSON::Object>(); |
| 438 | |
| 439 | Result<JSON::String> hostPath = |
| 440 | object.at<JSON::String>("PathOnHost"); |
| 441 | Result<JSON::String> containerPath = |
| 442 | object.at<JSON::String>("PathInContainer"); |
| 443 | Result<JSON::String> permissions = |
| 444 | object.at<JSON::String>("CgroupPermissions"); |
| 445 | |
| 446 | if (!hostPath.isSome() || |
| 447 | !containerPath.isSome() || |
| 448 | !permissions.isSome()) { |
| 449 | return Error("Malformed HostConfig.Devices entry" |
| 450 | " '" + stringify(object) + "'"); |
| 451 | } |
| 452 | |
| 453 | Device device; |
| 454 | device.hostPath = Path(hostPath->value); |
| 455 | device.containerPath = Path(containerPath->value); |
| 456 | device.access.read = strings::contains(permissions->value, "r"); |
| 457 | device.access.write = strings::contains(permissions->value, "w"); |
| 458 | device.access.mknod = strings::contains(permissions->value, "m"); |
| 459 | |
| 460 | devices.push_back(device); |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | vector<string> dns; |
no test coverage detected