Allowed new redirect config options to be pased as env vars to the docker image

This commit is contained in:
Alejandro Celaya
2020-06-20 11:21:37 +02:00
parent f2f07be11f
commit 5c163490c7
6 changed files with 23 additions and 3 deletions

View File

@@ -11,6 +11,7 @@ use PUGX\Shortid\Factory as ShortIdFactory;
use function sprintf;
const DEFAULT_DELETE_SHORT_URL_THRESHOLD = 15;
const DEFAULT_SHORT_CODES_LENGTH = 5;
const MIN_SHORT_CODES_LENGTH = 4;
const DEFAULT_REDIRECT_STATUS_CODE = StatusCodeInterface::STATUS_FOUND;

View File

@@ -38,6 +38,8 @@ class SimplifiedConfigParser
'mercure_internal_hub_url' => ['mercure', 'internal_hub_url'],
'mercure_jwt_secret' => ['mercure', 'jwt_secret'],
'anonymize_remote_addr' => ['url_shortener', 'anonymize_remote_addr'],
'redirect_status_code' => ['url_shortener', 'redirect_status_code'],
'redirect_cache_lifetime' => ['url_shortener', 'redirect_cache_lifetime'],
];
private const SIMPLIFIED_CONFIG_SIDE_EFFECTS = [
'delete_short_url_threshold' => [

View File

@@ -6,9 +6,11 @@ namespace Shlinkio\Shlink\Core\Options;
use Laminas\Stdlib\AbstractOptions;
use const Shlinkio\Shlink\Core\DEFAULT_DELETE_SHORT_URL_THRESHOLD;
class DeleteShortUrlsOptions extends AbstractOptions
{
private int $visitsThreshold = 15;
private int $visitsThreshold = DEFAULT_DELETE_SHORT_URL_THRESHOLD;
private bool $checkVisitsThreshold = true;
public function getVisitsThreshold(): int

View File

@@ -65,6 +65,8 @@ class SimplifiedConfigParserTest extends TestCase
'mercure_internal_hub_url' => 'internal_url',
'mercure_jwt_secret' => 'super_secret_value',
'anonymize_remote_addr' => false,
'redirect_status_code' => 301,
'redirect_cache_lifetime' => 90,
];
$expected = [
'app_options' => [
@@ -94,6 +96,8 @@ class SimplifiedConfigParserTest extends TestCase
],
'default_short_codes_length' => 8,
'anonymize_remote_addr' => false,
'redirect_status_code' => 301,
'redirect_cache_lifetime' => 90,
],
'delete_short_urls' => [