feat(docker): add HTTP Basic Authentication support and enhance hostname parsing in Docker run conversion
This commit is contained in:
@@ -453,6 +453,9 @@ function fqdnLabelsForTraefik(string $uuid, Collection $domains, bool $is_force_
|
|||||||
$labels = $labels->merge($redirect_to_www);
|
$labels = $labels->merge($redirect_to_www);
|
||||||
$middlewares->push($to_www_name);
|
$middlewares->push($to_www_name);
|
||||||
}
|
}
|
||||||
|
if ($http_basic_auth_enabled) {
|
||||||
|
$middlewares->push($http_basic_auth_label);
|
||||||
|
}
|
||||||
$middlewares_from_labels->each(function ($middleware_name) use ($middlewares) {
|
$middlewares_from_labels->each(function ($middleware_name) use ($middlewares) {
|
||||||
$middlewares->push($middleware_name);
|
$middlewares->push($middleware_name);
|
||||||
});
|
});
|
||||||
@@ -476,6 +479,9 @@ function fqdnLabelsForTraefik(string $uuid, Collection $domains, bool $is_force_
|
|||||||
$labels = $labels->merge($redirect_to_www);
|
$labels = $labels->merge($redirect_to_www);
|
||||||
$middlewares->push($to_www_name);
|
$middlewares->push($to_www_name);
|
||||||
}
|
}
|
||||||
|
if ($http_basic_auth_enabled) {
|
||||||
|
$middlewares->push($http_basic_auth_label);
|
||||||
|
}
|
||||||
$middlewares_from_labels->each(function ($middleware_name) use ($middlewares) {
|
$middlewares_from_labels->each(function ($middleware_name) use ($middlewares) {
|
||||||
$middlewares->push($middleware_name);
|
$middlewares->push($middleware_name);
|
||||||
});
|
});
|
||||||
@@ -772,6 +778,13 @@ function convertDockerRunToCompose(?string $custom_docker_run_options = null)
|
|||||||
$options[$option][] = $value;
|
$options[$option][] = $value;
|
||||||
$options[$option] = array_unique($options[$option]);
|
$options[$option] = array_unique($options[$option]);
|
||||||
}
|
}
|
||||||
|
if ($option === '--hostname') {
|
||||||
|
$regexForParsingHostname = '/hostname=([^\s]+)/';
|
||||||
|
preg_match($regexForParsingHostname, $custom_docker_run_options, $hostname_matches);
|
||||||
|
$value = $hostname_matches[1] ?? null;
|
||||||
|
$options[$option][] = $value;
|
||||||
|
$options[$option] = array_unique($options[$option]);
|
||||||
|
}
|
||||||
if (isset($match[2]) && $match[2] !== '') {
|
if (isset($match[2]) && $match[2] !== '') {
|
||||||
$value = $match[2];
|
$value = $match[2];
|
||||||
$options[$option][] = $value;
|
$options[$option][] = $value;
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
test('ConvertCapAdd', function () {
|
test('ConvertCapAdd', function () {
|
||||||
$input = '--cap-add=NET_ADMIN --cap-add=NET_RAW --cap-add SYS_ADMIN --hostname=test';
|
$input = '--cap-add=NET_ADMIN --cap-add=NET_RAW --cap-add SYS_ADMIN --hostname=my-super-host';
|
||||||
$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',
|
'hostname' => 'my-super-host',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user