diff --git a/src/functions.php b/src/functions.php index ea031a9..8dbf7b2 100644 --- a/src/functions.php +++ b/src/functions.php @@ -174,6 +174,10 @@ function applyGraphvizStyle(Graph $graph, bool $horizontal) : Graph if (($alias = $edge->getAttribute('docker_compose.alias')) !== null) { $edge->setAttribute('graphviz.label', $alias); + + if ($edge->getAttribute('docker_compose.condition') !== null) { + $edge->setAttribute('graphviz.fontsize', '10'); + } } if ($edge->getAttribute('docker_compose.bidir')) { @@ -260,7 +264,10 @@ function makeVerticesAndEdges(Graph $graph, array $services, array $volumes, arr addRelation( $graph->getVertex($service), addService($graph, is_array($dependency) ? $key : $dependency), - 'depends_on' + 'depends_on', + is_array($dependency) && isset($dependency['condition']) ? $dependency['condition'] : null, + false, + is_array($dependency) && isset($dependency['condition']) ); } @@ -418,10 +425,11 @@ function addNetwork(Graph $graph, string $name, string $type = null) * @param string $type Type of the relation (one of "links", "volumes_from", "depends_on", "ports"); * @param string|null $alias Alias associated to the linked element * @param bool|null $bidirectional Biderectional or not + * @param bool|null $condition Wether the alias represents a condition or not * * @return Edge\Directed */ -function addRelation(Vertex $from, Vertex $to, string $type, string $alias = null, bool $bidirectional = false) : Edge\Directed +function addRelation(Vertex $from, Vertex $to, string $type, string $alias = null, bool $bidirectional = false, bool $condition = false) : Edge\Directed { $edge = null; @@ -445,6 +453,10 @@ function addRelation(Vertex $from, Vertex $to, string $type, string $alias = nul $edge->setAttribute('docker_compose.alias', $alias); } + if (true === $condition) { + $edge->setAttribute('docker_compose.condition', true); + } + $edge->setAttribute('docker_compose.bidir', $bidirectional); return $edge;