Skip to content

Commit f4d5446

Browse files
committed
Add support for traefik 2+ labels
Update vendor file versions to SF 5
1 parent 4e4a383 commit f4d5446

File tree

7 files changed

+78
-77
lines changed

7 files changed

+78
-77
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,7 @@ Network Trash Folder
8888
Temporary Items
8989
.apdisk
9090
/somnambulist-project-manager_checksums.txt
91+
92+
93+
# PhpStorm 2020.2+ now stores hardcoded paths in the CLI tool config
94+
/.idea/commandlinetools/Symfony*.xml

.idea/commandlinetools/schemas/frameworkDescriptionVersion1.1.4.xsd

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php.xml

Lines changed: 0 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/project-manager.iml

Lines changed: 0 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
"ext-ctype": "*",
99
"ext-iconv": "*",
1010
"ext-json": "*",
11-
"pragmarx/ia-str": "~5.8",
11+
"pragmarx/ia-str": "~7.3",
1212
"somnambulist/collection": "~3.2",
13-
"symfony/config": "4.4.*",
14-
"symfony/console": "4.4.*",
15-
"symfony/dependency-injection": "4.4.*",
16-
"symfony/dotenv": "4.4.*",
17-
"symfony/finder": "4.4.*",
18-
"symfony/http-kernel": "4.4.*",
19-
"symfony/process": "4.4.*",
20-
"symfony/yaml": "4.4.*"
13+
"symfony/config": "5.1.*",
14+
"symfony/console": "5.1.*",
15+
"symfony/dependency-injection": "5.1.*",
16+
"symfony/dotenv": "5.1.*",
17+
"symfony/finder": "5.1.*",
18+
"symfony/http-kernel": "5.1.*",
19+
"symfony/process": "5.1.*",
20+
"symfony/yaml": "5.1.*"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "~8",
24-
"symfony/var-dumper": "4.4.*"
23+
"phpunit/phpunit": "~9",
24+
"symfony/var-dumper": "5.1.*"
2525
},
2626
"config": {
2727
"preferred-install": {

src/Commands/Services/StatusCommand.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private function displayTable(OutputInterface $output, Project $project, Mutable
113113
$table = new Table($output);
114114
$table
115115
->setHeaderTitle(sprintf('Services Status (project: <fg=yellow;bg=white>%s</>)', $project->name()))
116-
->setHeaders(['Running Container Name', 'Status', 'Host', 'Port', 'Mounts', 'SyncIt'])
116+
->setHeaders(['Running Container Name', 'Status', 'Host', 'Port', 'Mounts', 'Mutagen'])
117117
->addRows($data->toArray())
118118
;
119119

@@ -209,16 +209,23 @@ private function getLabelsFromString(string $string): MutableCollection
209209

210210
private function getHostFromLabels(MutableCollection $labels): string
211211
{
212-
$host = trim(str_replace('Host:', '', $labels->get('traefik.frontend.rule', '')));
213-
214-
if (strpos($labels->get('com.docker.compose.service'), 'db-') === 0) {
212+
if (strpos($labels->get('com.docker.compose.service', ''), 'db-') === 0) {
215213
if (array_key_exists('DOCKER_HOST', $_SERVER)) {
216-
$host = parse_url($_SERVER['DOCKER_HOST'], PHP_URL_HOST);
217-
} else {
218-
$host = 'localhost';
214+
return parse_url($_SERVER['DOCKER_HOST'], PHP_URL_HOST);
219215
}
216+
217+
return 'localhost';
218+
}
219+
220+
if (!$labels->has('traefik.enable') || !$labels->get('traefik.enable')) {
221+
return '';
220222
}
221223

222-
return $host;
224+
return
225+
$labels
226+
->filter(function ($value, $key) { return false !== strpos($key, '.rule'); })
227+
->map(function ($value) { return trim(str_replace(['Host', 'host', ':', '(', '`', ')'], '', $value)); })
228+
->first() ?? ''
229+
;
223230
}
224231
}

src/Services/Compiler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function compile($pharFile = 'somnambulist-project-manager.phar')
6565
->in($basePath . '/vendor/psr/')
6666
->in($basePath . '/vendor/somnambulist/')
6767
->in($basePath . '/vendor/symfony/')
68+
->in($basePath . '/vendor/voku/')
6869
->sort($finderSort)
6970
;
7071

0 commit comments

Comments
 (0)