mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-04 10:42:23 +00:00
fix(docker): handle commas in container label values (#11477)
This commit is contained in:
1 parent
16352fad23
commit
3da7f5a5a5
2 files changed
+18
-4
No files matched your search
@@ -166,11 +166,13 @@ function format_docker_labels_to_json(string|array $rawOutput): Collection
|
||||
$outputArray = explode(',', $outputLine);
|
||||
|
||||
return collect($outputArray)
|
||||
->map(function ($outputLine) {
|
||||
return explode('=', $outputLine);
|
||||
})
|
||||
->mapWithKeys(function ($outputLine) {
|
||||
return [$outputLine[0] => $outputLine[1]];
|
||||
$label = explode('=', $outputLine, 2);
|
||||
if (count($label) !== 2) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [$label[0] => $label[1]];
|
||||
});
|
||||
})[0];
|
||||
}
|
||||
|
||||
@@ -94,6 +94,18 @@ it('filters service sub containers in PHP instead of using user input in shell f
|
||||
->toBe(['first', 'third']);
|
||||
});
|
||||
|
||||
it('filters service containers when another Docker label contains commas', function () {
|
||||
$containers = collect([
|
||||
[
|
||||
'ID' => 'app',
|
||||
'Labels' => 'traefik.http.routers.app.rule=Host(`one.example.com`,`two.example.com`),coolify.name=app-service-uuid',
|
||||
],
|
||||
]);
|
||||
|
||||
expect(filterServiceSubContainersByName($containers, 'app-service-uuid')->pluck('ID')->all())
|
||||
->toBe(['app']);
|
||||
});
|
||||
|
||||
it('does not interpolate the requested service name into the docker ps shell command', function () {
|
||||
$source = file_get_contents(__DIR__.'/../../../bootstrap/helpers/docker.php');
|
||||
|
||||
|
||||
Reference in new issue
Block a user