Merge pull request #23 from pmsipilot/conditions-depends-on
Conditions depends on
This commit is contained in:
commit
add1fa32c0
2 changed files with 18 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
|||
# `1.1.0` (unreleased)
|
||||
|
||||
* Display `depends_on` conditions
|
||||
* Handle conditions in `depends_on`
|
||||
* Automatically load override file if it exists or ignore it using `--ignore-override`
|
||||
|
||||
# `1.0.0`
|
||||
|
|
|
@ -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')) {
|
||||
|
@ -256,11 +260,14 @@ function makeVerticesAndEdges(Graph $graph, array $services, array $volumes, arr
|
|||
);
|
||||
}
|
||||
|
||||
foreach ($definition['depends_on'] ?? [] as $dependency) {
|
||||
foreach ($definition['depends_on'] ?? [] as $key => $dependency) {
|
||||
addRelation(
|
||||
$graph->getVertex($service),
|
||||
addService($graph, $dependency),
|
||||
'depends_on'
|
||||
addService($graph, is_array($dependency) ? $key : $dependency),
|
||||
'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;
|
||||
|
|
Loading…
Reference in a new issue