-
Notifications
You must be signed in to change notification settings - Fork 5
/
DockerEngineResource.php
64 lines (56 loc) 路 1.74 KB
/
DockerEngineResource.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace Infra\Resource;
use GraphQL\Type\Definition\Type;
use Graph\Graph;
class DockerEngineResource extends AbstractResource
{
public function getAddress(): ?string
{
return $this->spec['address'] ?? null;
}
public function getPort(): ?int
{
return $this->spec['port'] ?? null;
}
public function getApps(): array
{
/** @var DockerAppResource[] $apps */
$apps = $this->graph->getResourcesByType('DockerApp');
$res = [];
foreach ($apps as $app) {
if ($app->hasDockerEngineName($this->getName())) {
$res[] = $app;
}
}
return $res;
}
public static function getConfig(Graph $graph): array
{
return [
'name' => 'DockerEngine',
'fields' => [
'name' => Type::id(),
'description' => [
'type' => Type::string(),
'description' => 'Description',
],
'labels' => [
'type' => Type::listOf($graph->getType('Label')),
'description' => 'Returns all labels',
],
'address' => [
'type' => Type::string(),
'description' => 'Docker Engine IP address',
],
'port' => [
'type' => Type::int(),
'description' => 'Docker Engine Port',
],
'apps' => [
'type' => Type::listOf($graph->getType('DockerApp')),
'description' => 'Docker Apps',
],
],
];
}
}