refactor(docker): remove debug statement and enhance hostname handling in Docker run conversion
This commit is contained in:
@@ -582,7 +582,6 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview
|
|||||||
if ($pull_request_id !== 0) {
|
if ($pull_request_id !== 0) {
|
||||||
$appUuid = $appUuid.'-pr-'.$pull_request_id;
|
$appUuid = $appUuid.'-pr-'.$pull_request_id;
|
||||||
}
|
}
|
||||||
ray($application);
|
|
||||||
$labels = collect([]);
|
$labels = collect([]);
|
||||||
if ($pull_request_id === 0) {
|
if ($pull_request_id === 0) {
|
||||||
if ($application->fqdn) {
|
if ($application->fqdn) {
|
||||||
@@ -749,7 +748,6 @@ function convertDockerRunToCompose(?string $custom_docker_run_options = null)
|
|||||||
'--ulimit',
|
'--ulimit',
|
||||||
'--device',
|
'--device',
|
||||||
'--shm-size',
|
'--shm-size',
|
||||||
'--hostname',
|
|
||||||
]);
|
]);
|
||||||
$mapping = collect([
|
$mapping = collect([
|
||||||
'--cap-add' => 'cap_add',
|
'--cap-add' => 'cap_add',
|
||||||
@@ -763,7 +761,7 @@ function convertDockerRunToCompose(?string $custom_docker_run_options = null)
|
|||||||
'--ip' => 'ip',
|
'--ip' => 'ip',
|
||||||
'--shm-size' => 'shm_size',
|
'--shm-size' => 'shm_size',
|
||||||
'--gpus' => 'gpus',
|
'--gpus' => 'gpus',
|
||||||
'--hostname' => 'hostname'
|
'--hostname' => 'hostname',
|
||||||
]);
|
]);
|
||||||
foreach ($matches as $match) {
|
foreach ($matches as $match) {
|
||||||
$option = $match[1];
|
$option = $match[1];
|
||||||
@@ -810,7 +808,7 @@ function convertDockerRunToCompose(?string $custom_docker_run_options = null)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
$compose_options->put($mapping[$option], $ulimits);
|
$compose_options->put($mapping[$option], $ulimits);
|
||||||
} elseif ($option === '--shm-size') {
|
} elseif ($option === '--shm-size' || $option === '--hostname') {
|
||||||
if (! is_null($value) && is_array($value) && count($value) > 0) {
|
if (! is_null($value) && is_array($value) && count($value) > 0) {
|
||||||
$compose_options->put($mapping[$option], $value[0]);
|
$compose_options->put($mapping[$option], $value[0]);
|
||||||
}
|
}
|
||||||
@@ -849,7 +847,6 @@ function convertDockerRunToCompose(?string $custom_docker_run_options = null)
|
|||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$compose_options->forget($option);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
test('ConvertCapAdd', function () {
|
test('ConvertCapAdd', function () {
|
||||||
$input = '--cap-add=NET_ADMIN --cap-add=NET_RAW --cap-add SYS_ADMIN';
|
$input = '--cap-add=NET_ADMIN --cap-add=NET_RAW --cap-add SYS_ADMIN --hostname=test';
|
||||||
$output = convertDockerRunToCompose($input);
|
$output = convertDockerRunToCompose($input);
|
||||||
expect($output)->toBe([
|
expect($output)->toBe([
|
||||||
'cap_add' => ['NET_ADMIN', 'NET_RAW', 'SYS_ADMIN'],
|
'cap_add' => ['NET_ADMIN', 'NET_RAW', 'SYS_ADMIN'],
|
||||||
|
'hostname' => 'test',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user