chore: Update dependencies
This commit is contained in:
parent
27758c0f0a
commit
f6f67be46c
7 changed files with 660 additions and 172 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@ bin/
|
|||
!bin/dcv
|
||||
!bin/entrypoint.sh
|
||||
.cache/
|
||||
.php_cs.cache
|
||||
|
|
13
.php_cs
13
.php_cs
|
@ -1,12 +1,15 @@
|
|||
<?php
|
||||
|
||||
$finder = Symfony\CS\Finder\DefaultFinder::create()
|
||||
->exclude('somedir')
|
||||
use PhpCsFixer as CS;
|
||||
|
||||
$finder = CS\Finder::create()
|
||||
->in(__DIR__.DIRECTORY_SEPARATOR.'src')
|
||||
->in(__DIR__.DIRECTORY_SEPARATOR.'spec')
|
||||
;
|
||||
|
||||
return Symfony\CS\Config\Config::create()
|
||||
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
|
||||
->finder($finder)
|
||||
return CS\Config::create()
|
||||
->setRules([
|
||||
'@Symfony' => true,
|
||||
])
|
||||
->setFinder($finder)
|
||||
;
|
||||
|
|
|
@ -8,12 +8,14 @@ services:
|
|||
php:
|
||||
- 7.0
|
||||
- 7.1
|
||||
- 7.2
|
||||
- nightly
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- COMPOSERFLAGS=
|
||||
- COMPOSERFLAGS=--prefer-lowest
|
||||
- COMPOSERFLAGS=--prefer-stable
|
||||
|
||||
global:
|
||||
# DOCKER_EMAIL
|
||||
|
@ -29,6 +31,8 @@ matrix:
|
|||
env: COMPOSERFLAGS=
|
||||
- php: 7.1
|
||||
env: COMPOSERFLAGS=--prefer-lowest
|
||||
- php: 7.2
|
||||
env: COMPOSERFLAGS=--prefer-lowest
|
||||
- php: nightly
|
||||
env: COMPOSERFLAGS=--prefer-lowest
|
||||
allow_failures:
|
||||
|
|
|
@ -2,14 +2,15 @@
|
|||
"name": "pmsipilot/docker-compose-viz",
|
||||
"description": "Docker compose graph visualization",
|
||||
"require": {
|
||||
"symfony/yaml": "^3.1 || ^4@dev",
|
||||
"php": "^7",
|
||||
"symfony/yaml": "^3.1 || ^4",
|
||||
"symfony/console": "^3.1",
|
||||
"clue/graph": "^0.9",
|
||||
"graphp/graphviz": "^0.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"crysalead/kahlan": "^2.5.4",
|
||||
"friendsofphp/php-cs-fixer": "^1.11"
|
||||
"friendsofphp/php-cs-fixer": "^2"
|
||||
},
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
|
|
731
composer.lock
generated
731
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -26,7 +26,7 @@ $application->register('render')
|
|||
->setCode(function (Console\Input\InputInterface $input, Console\Output\OutputInterface $output) {
|
||||
$backgroundColor = $input->getOption('background');
|
||||
|
||||
if (preg_match('/^#[a-fA-F0-9]{6}|transparent$/', $backgroundColor) === 0) {
|
||||
if (0 === preg_match('/^#[a-fA-F0-9]{6}|transparent$/', $backgroundColor)) {
|
||||
throw new Console\Exception\InvalidArgumentException(sprintf('Invalid background color "%s". It must be a valid hex color or "transparent".', $backgroundColor));
|
||||
}
|
||||
|
||||
|
@ -36,19 +36,19 @@ $application->register('render')
|
|||
$overrideFile = dirname($inputFile).DIRECTORY_SEPARATOR.basename($inputFile, '.'.$inputFileExtension).'.'.$input->getOption('override').'.'.$inputFileExtension;
|
||||
|
||||
$outputFormat = $input->getOption('output-format');
|
||||
$outputFile = $input->getOption('output-file') ?: getcwd().DIRECTORY_SEPARATOR.'docker-compose.'.($outputFormat === 'dot' ? $outputFormat : 'png');
|
||||
$outputFile = $input->getOption('output-file') ?: getcwd().DIRECTORY_SEPARATOR.'docker-compose.'.('dot' === $outputFormat ? $outputFormat : 'png');
|
||||
$onlyServices = $input->getOption('only');
|
||||
|
||||
if (in_array($outputFormat, ['dot', 'image', 'display']) === false) {
|
||||
if (false === in_array($outputFormat, ['dot', 'image', 'display'])) {
|
||||
throw new Console\Exception\InvalidArgumentException(sprintf('Invalid output format "%s". It must be one of "dot", "image" or "display".', $outputFormat));
|
||||
}
|
||||
|
||||
if ($outputFormat === 'display') {
|
||||
if ('display' === $outputFormat) {
|
||||
if ($input->getOption('force') || $input->getOption('output-file')) {
|
||||
$output->writeln('<comment>The following options are ignored with the "display" output format: "--force", "--output-file"</comment>');
|
||||
}
|
||||
} else {
|
||||
if (file_exists($outputFile) === true && $input->getOption('force') === false) {
|
||||
if (true === file_exists($outputFile) && false === $input->getOption('force')) {
|
||||
throw new Console\Exception\InvalidArgumentException(sprintf('File "%s" already exists. Use the "--force" option to overwrite it.', $outputFile));
|
||||
}
|
||||
}
|
||||
|
@ -103,19 +103,19 @@ $application->register('render')
|
|||
}
|
||||
|
||||
$flags = 0;
|
||||
if ($input->getOption('no-volumes') === true) {
|
||||
if (true === $input->getOption('no-volumes')) {
|
||||
$logger('<comment>Volumes</comment> will not be displayed');
|
||||
|
||||
$flags |= WITHOUT_VOLUMES;
|
||||
}
|
||||
|
||||
if ($input->getOption('no-networks') === true) {
|
||||
if (true === $input->getOption('no-networks')) {
|
||||
$logger('<comment>Networks</comment> will not be displayed');
|
||||
|
||||
$flags |= WITHOUT_NETWORKS;
|
||||
}
|
||||
|
||||
if ($input->getOption('no-ports') === true) {
|
||||
if (true === $input->getOption('no-ports')) {
|
||||
$logger('<comment>Ports</comment> will not be displayed');
|
||||
|
||||
$flags |= WITHOUT_PORTS;
|
||||
|
|
|
@ -20,7 +20,7 @@ const WITHOUT_PORTS = 4;
|
|||
*
|
||||
* @return callable
|
||||
*/
|
||||
function logger(OutputInterface $output) : callable
|
||||
function logger(OutputInterface $output): callable
|
||||
{
|
||||
return function (string $message, int $verbosity = null) use ($output) {
|
||||
$output->writeln(sprintf('[%s] %s', date(DATE_ISO8601), $message), $verbosity ?: OutputInterface::VERBOSITY_VERBOSE);
|
||||
|
@ -34,9 +34,9 @@ function logger(OutputInterface $output) : callable
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
function readConfiguration(string $path) : array
|
||||
function readConfiguration(string $path): array
|
||||
{
|
||||
if (file_exists($path) === false) {
|
||||
if (false === file_exists($path)) {
|
||||
throw new \InvalidArgumentException(sprintf('File "%s" does not exist', $path));
|
||||
}
|
||||
|
||||
|
@ -54,9 +54,9 @@ function readConfiguration(string $path) : array
|
|||
*
|
||||
* @return array List of service definitions exctracted from the configuration
|
||||
*/
|
||||
function fetchServices(array $configuration) : array
|
||||
function fetchServices(array $configuration): array
|
||||
{
|
||||
if (isset($configuration['version']) === false || (int) $configuration['version'] === 1) {
|
||||
if (false === isset($configuration['version']) || 1 === (int) $configuration['version']) {
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
|
@ -70,9 +70,9 @@ function fetchServices(array $configuration) : array
|
|||
*
|
||||
* @return array List of service definitions exctracted from the configuration
|
||||
*/
|
||||
function fetchVolumes(array $configuration) : array
|
||||
function fetchVolumes(array $configuration): array
|
||||
{
|
||||
if (isset($configuration['version']) === false || (int) $configuration['version'] === 1) {
|
||||
if (false === isset($configuration['version']) || 1 === (int) $configuration['version']) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -86,9 +86,9 @@ function fetchVolumes(array $configuration) : array
|
|||
*
|
||||
* @return array List of service definitions exctracted from the configuration
|
||||
*/
|
||||
function fetchNetworks(array $configuration) : array
|
||||
function fetchNetworks(array $configuration): array
|
||||
{
|
||||
if (isset($configuration['version']) === false || (int) $configuration['version'] === 1) {
|
||||
if (false === isset($configuration['version']) || 1 === (int) $configuration['version']) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ function fetchNetworks(array $configuration) : array
|
|||
*
|
||||
* @return Graph The complete graph for the given list of services
|
||||
*/
|
||||
function createGraph(array $services, array $volumes, array $networks, string $path, int $flags) : Graph
|
||||
function createGraph(array $services, array $volumes, array $networks, string $path, int $flags): Graph
|
||||
{
|
||||
return makeVerticesAndEdges(new Graph(), $services, $volumes, $networks, $path, $flags);
|
||||
}
|
||||
|
@ -120,14 +120,14 @@ function createGraph(array $services, array $volumes, array $networks, string $p
|
|||
*
|
||||
* @return Graph A copy of the input graph with style attributes
|
||||
*/
|
||||
function applyGraphvizStyle(Graph $graph, bool $horizontal, string $background) : Graph
|
||||
function applyGraphvizStyle(Graph $graph, bool $horizontal, string $background): Graph
|
||||
{
|
||||
$graph = $graph->createGraphClone();
|
||||
$graph->setAttribute('graphviz.graph.bgcolor', $background);
|
||||
$graph->setAttribute('graphviz.graph.pad', '0.5');
|
||||
$graph->setAttribute('graphviz.graph.ratio', 'fill');
|
||||
|
||||
if ($horizontal === true) {
|
||||
if (true === $horizontal) {
|
||||
$graph->setAttribute('graphviz.graph.rankdir', 'LR');
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ function applyGraphvizStyle(Graph $graph, bool $horizontal, string $background)
|
|||
case 'port':
|
||||
$vertex->setAttribute('graphviz.shape', 'circle');
|
||||
|
||||
if (($proto = $vertex->getAttribute('docker_compose.proto')) === 'udp') {
|
||||
if ('udp' === ($proto = $vertex->getAttribute('docker_compose.proto'))) {
|
||||
$vertex->setAttribute('graphviz.style', 'dashed');
|
||||
}
|
||||
break;
|
||||
|
@ -193,10 +193,10 @@ function applyGraphvizStyle(Graph $graph, bool $horizontal, string $background)
|
|||
break;
|
||||
}
|
||||
|
||||
if (($alias = $edge->getAttribute('docker_compose.alias')) !== null) {
|
||||
if (null !== ($alias = $edge->getAttribute('docker_compose.alias'))) {
|
||||
$edge->setAttribute('graphviz.label', $alias);
|
||||
|
||||
if ($edge->getAttribute('docker_compose.condition') !== null) {
|
||||
if (null !== $edge->getAttribute('docker_compose.condition')) {
|
||||
$edge->setAttribute('graphviz.fontsize', '10');
|
||||
}
|
||||
}
|
||||
|
@ -220,19 +220,19 @@ function applyGraphvizStyle(Graph $graph, bool $horizontal, string $background)
|
|||
*
|
||||
* @return Graph A copy of the input graph with vertices and edges for services
|
||||
*/
|
||||
function makeVerticesAndEdges(Graph $graph, array $services, array $volumes, array $networks, string $path, int $flags) : Graph
|
||||
function makeVerticesAndEdges(Graph $graph, array $services, array $volumes, array $networks, string $path, int $flags): Graph
|
||||
{
|
||||
if (((bool) ($flags & WITHOUT_VOLUMES)) === false) {
|
||||
if (false === ((bool) ($flags & WITHOUT_VOLUMES))) {
|
||||
foreach (array_keys($volumes) as $volume) {
|
||||
addVolume($graph, 'named: '.$volume);
|
||||
}
|
||||
}
|
||||
|
||||
if (((bool) ($flags & WITHOUT_NETWORKS)) === false) {
|
||||
if (false === ((bool) ($flags & WITHOUT_NETWORKS))) {
|
||||
foreach ($networks as $network => $definition) {
|
||||
addNetwork(
|
||||
$graph, 'net: '.$network,
|
||||
isset($definition['external']) && $definition['external'] === true ? 'external_network' : 'network'
|
||||
isset($definition['external']) && true === $definition['external'] ? 'external_network' : 'network'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ function makeVerticesAndEdges(Graph $graph, array $services, array $volumes, arr
|
|||
);
|
||||
}
|
||||
|
||||
if (((bool) ($flags & WITHOUT_VOLUMES)) === false) {
|
||||
if (false === ((bool) ($flags & WITHOUT_VOLUMES))) {
|
||||
$serviceVolumes = [];
|
||||
|
||||
foreach ($definition['volumes'] ?? [] as $volume) {
|
||||
|
@ -314,7 +314,7 @@ function makeVerticesAndEdges(Graph $graph, array $services, array $volumes, arr
|
|||
foreach ($serviceVolumes as $container => $volume) {
|
||||
list($host, $attr) = $volume;
|
||||
|
||||
if ($host[0] !== '.' && $host[0] !== DIRECTORY_SEPARATOR) {
|
||||
if ('.' !== $host[0] && DIRECTORY_SEPARATOR !== $host[0]) {
|
||||
$host = 'named: '.$host;
|
||||
}
|
||||
|
||||
|
@ -323,12 +323,12 @@ function makeVerticesAndEdges(Graph $graph, array $services, array $volumes, arr
|
|||
$graph->getVertex($service),
|
||||
'volumes',
|
||||
$host !== $container ? $container : null,
|
||||
$attr !== 'ro'
|
||||
'ro' !== $attr
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (((bool) ($flags & WITHOUT_PORTS)) === false) {
|
||||
if (false === ((bool) ($flags & WITHOUT_PORTS))) {
|
||||
foreach ($definition['ports'] ?? [] as $port) {
|
||||
list($host, $container, $proto) = explodeMapping($port);
|
||||
|
||||
|
@ -341,7 +341,7 @@ function makeVerticesAndEdges(Graph $graph, array $services, array $volumes, arr
|
|||
}
|
||||
}
|
||||
|
||||
if (((bool) ($flags & WITHOUT_NETWORKS)) === false) {
|
||||
if (false === ((bool) ($flags & WITHOUT_NETWORKS))) {
|
||||
foreach ($definition['networks'] ?? [] as $network => $config) {
|
||||
$network = is_int($network) ? $config : $network;
|
||||
$config = is_int($network) ? [] : $config;
|
||||
|
@ -371,7 +371,7 @@ function makeVerticesAndEdges(Graph $graph, array $services, array $volumes, arr
|
|||
*/
|
||||
function addService(Graph $graph, string $service, string $type = null)
|
||||
{
|
||||
if ($graph->hasVertex($service) === true) {
|
||||
if (true === $graph->hasVertex($service)) {
|
||||
return $graph->getVertex($service);
|
||||
}
|
||||
|
||||
|
@ -392,7 +392,7 @@ function addService(Graph $graph, string $service, string $type = null)
|
|||
*/
|
||||
function addPort(Graph $graph, int $port, string $proto = null)
|
||||
{
|
||||
if ($graph->hasVertex($port) === true) {
|
||||
if (true === $graph->hasVertex($port)) {
|
||||
return $graph->getVertex($port);
|
||||
}
|
||||
|
||||
|
@ -413,7 +413,7 @@ function addPort(Graph $graph, int $port, string $proto = null)
|
|||
*/
|
||||
function addVolume(Graph $graph, string $path)
|
||||
{
|
||||
if ($graph->hasVertex($path) === true) {
|
||||
if (true === $graph->hasVertex($path)) {
|
||||
return $graph->getVertex($path);
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@ function addVolume(Graph $graph, string $path)
|
|||
*/
|
||||
function addNetwork(Graph $graph, string $name, string $type = null)
|
||||
{
|
||||
if ($graph->hasVertex($name) === true) {
|
||||
if (true === $graph->hasVertex($name)) {
|
||||
return $graph->getVertex($name);
|
||||
}
|
||||
|
||||
|
@ -456,7 +456,7 @@ function addNetwork(Graph $graph, string $name, string $type = null)
|
|||
*
|
||||
* @return Edge\Directed
|
||||
*/
|
||||
function addRelation(Vertex $from, Vertex $to, string $type, string $alias = null, bool $bidirectional = false, bool $condition = false) : Edge\Directed
|
||||
function addRelation(Vertex $from, Vertex $to, string $type, string $alias = null, bool $bidirectional = false, bool $condition = false): Edge\Directed
|
||||
{
|
||||
$edge = null;
|
||||
|
||||
|
@ -476,7 +476,7 @@ function addRelation(Vertex $from, Vertex $to, string $type, string $alias = nul
|
|||
|
||||
$edge->setAttribute('docker_compose.type', $type);
|
||||
|
||||
if ($alias !== null) {
|
||||
if (null !== $alias) {
|
||||
$edge->setAttribute('docker_compose.alias', $alias);
|
||||
}
|
||||
|
||||
|
@ -497,7 +497,7 @@ function addRelation(Vertex $from, Vertex $to, string $type, string $alias = nul
|
|||
* @return array An 2 items array containing the parts of the mapping.
|
||||
* If the mapping does not specify a second part, the first one will be repeated
|
||||
*/
|
||||
function explodeMapping($mapping) : array
|
||||
function explodeMapping($mapping): array
|
||||
{
|
||||
$parts = explode(':', $mapping);
|
||||
$parts[1] = $parts[1] ?? $parts[0];
|
||||
|
|
Loading…
Reference in a new issue