add Docker run command parse test
This commit is contained in:
parent
29676ffb22
commit
798d747164
@ -349,18 +349,8 @@ function convert_docker_run_to_compose(?string $custom_docker_run_options = null
|
|||||||
foreach ($matches as $match) {
|
foreach ($matches as $match) {
|
||||||
$option = $match[1];
|
$option = $match[1];
|
||||||
$value = isset($match[2]) && $match[2] !== '' ? $match[2] : true;
|
$value = isset($match[2]) && $match[2] !== '' ? $match[2] : true;
|
||||||
if ($list_options->contains($option)) {
|
$options[$option][] = $value;
|
||||||
$value = explode(',', $value);
|
$options[$option] = array_unique($options[$option]);
|
||||||
}
|
|
||||||
if (array_key_exists($option, $options)) {
|
|
||||||
if (is_array($options[$option])) {
|
|
||||||
$options[$option][] = $value;
|
|
||||||
} else {
|
|
||||||
$options[$option] = [$options[$option], $value];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$options[$option] = $value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$options = collect($options);
|
$options = collect($options);
|
||||||
// Easily get mappings from https://github.com/composerize/composerize/blob/master/packages/composerize/src/mappings.js
|
// Easily get mappings from https://github.com/composerize/composerize/blob/master/packages/composerize/src/mappings.js
|
||||||
@ -370,7 +360,7 @@ function convert_docker_run_to_compose(?string $custom_docker_run_options = null
|
|||||||
}
|
}
|
||||||
if ($option === '--ulimit') {
|
if ($option === '--ulimit') {
|
||||||
$ulimits = collect([]);
|
$ulimits = collect([]);
|
||||||
collect($value)->map(function ($ulimit) use ($ulimits){
|
collect($value)->map(function ($ulimit) use ($ulimits) {
|
||||||
$ulimit = explode('=', $ulimit);
|
$ulimit = explode('=', $ulimit);
|
||||||
$type = $ulimit[0];
|
$type = $ulimit[0];
|
||||||
$limits = explode(':', $ulimit[1]);
|
$limits = explode(':', $ulimit[1]);
|
||||||
@ -381,7 +371,6 @@ function convert_docker_run_to_compose(?string $custom_docker_run_options = null
|
|||||||
'soft' => $soft_limit,
|
'soft' => $soft_limit,
|
||||||
'hard' => $hard_limit
|
'hard' => $hard_limit
|
||||||
]);
|
]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$soft_limit = $ulimit[1];
|
$soft_limit = $ulimit[1];
|
||||||
$ulimits->put($type, [
|
$ulimits->put($type, [
|
||||||
|
9
tests/Feature/DockerRunTest.php
Normal file
9
tests/Feature/DockerRunTest.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
it('ConvertDockerTunCommand', function () {
|
||||||
|
$input = '--cap-add=NET_ADMIN --cap-add=NET_RAW --cap-add SYS_ADMIN';
|
||||||
|
$output = convert_docker_run_to_compose($input);
|
||||||
|
expect($output)->toBe([
|
||||||
|
'cap_add' => ['NET_ADMIN', 'NET_RAW', 'SYS_ADMIN'],
|
||||||
|
])->ray();
|
||||||
|
});
|
@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
it('returns a successful response', function () {
|
|
||||||
$response = $this->get('/api/health');
|
|
||||||
|
|
||||||
$response->assertStatus(200);
|
|
||||||
});
|
|
@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
test('parse', function () {
|
|
||||||
|
|
||||||
expect($result)->toBe(3);
|
|
||||||
});
|
|
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
uses(
|
uses(
|
||||||
Tests\TestCase::class,
|
// Tests\TestCase::class,
|
||||||
// Illuminate\Foundation\Testing\RefreshDatabase::class,
|
// Illuminate\Foundation\Testing\RefreshDatabase::class,
|
||||||
)->in('Feature');
|
)->in('Feature');
|
||||||
|
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
test('that true is true', function () {
|
|
||||||
expect(true)->toBeTrue();
|
|
||||||
});
|
|
@ -1,5 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
test('globals')
|
|
||||||
->expect(['dd', 'dump'])
|
|
||||||
->not->toBeUsed();
|
|
Loading…
Reference in New Issue
Block a user