mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-01 21:09:27 -06:00
Merge pull request #1500 from acelaya-forks/feature/fix-env-var-loading
Feature/fix env var loading
This commit is contained in:
commit
af9ea13933
@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).
|
||||
|
||||
## [Unreleased]
|
||||
## [3.2.1] - 2022-08-08
|
||||
### Added
|
||||
* *Nothing*
|
||||
|
||||
@ -19,7 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
|
||||
* *Nothing*
|
||||
|
||||
### Fixed
|
||||
* *Nothing*
|
||||
* [#1499](https://github.com/shlinkio/shlink/issues/1499) Fixed loading of config options as env vars, which was making all default configurations to be loaded unless env vars were explicitly provided.
|
||||
|
||||
|
||||
## [3.2.0] - 2022-08-05
|
||||
|
@ -43,11 +43,11 @@
|
||||
"php-middleware/request-id": "^4.1",
|
||||
"pugx/shortid-php": "^1.0",
|
||||
"ramsey/uuid": "^4.3",
|
||||
"shlinkio/shlink-common": "dev-main#5251f37 as 5.0",
|
||||
"shlinkio/shlink-common": "^5.0",
|
||||
"shlinkio/shlink-config": "^2.0",
|
||||
"shlinkio/shlink-event-dispatcher": "^2.5",
|
||||
"shlinkio/shlink-importer": "^4.0",
|
||||
"shlinkio/shlink-installer": "dev-develop#c6032b1 as 8.1",
|
||||
"shlinkio/shlink-installer": "^8.1",
|
||||
"shlinkio/shlink-ip-geolocation": "^3.0",
|
||||
"symfony/console": "^6.1",
|
||||
"symfony/filesystem": "^6.1",
|
||||
|
@ -21,7 +21,7 @@ $isTestEnv = env('APP_ENV') === 'test';
|
||||
|
||||
return (new ConfigAggregator\ConfigAggregator([
|
||||
! $isTestEnv
|
||||
? new EnvVarLoaderProvider('config/params/generated_config.php', Core\Config\EnvVars::cases())
|
||||
? new EnvVarLoaderProvider('config/params/generated_config.php', Core\Config\EnvVars::values())
|
||||
: new ConfigAggregator\ArrayProvider([]),
|
||||
Mezzio\ConfigProvider::class,
|
||||
Mezzio\Router\ConfigProvider::class,
|
||||
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Core\Config;
|
||||
|
||||
use function Functional\map;
|
||||
use function Shlinkio\Shlink\Config\env;
|
||||
|
||||
enum EnvVars: string
|
||||
@ -74,4 +75,13 @@ enum EnvVars: string
|
||||
{
|
||||
return $this->loadFromEnv() !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public static function values(): array
|
||||
{
|
||||
static $values;
|
||||
return $values ?? ($values = map(self::cases(), static fn (EnvVars $envVar) => $envVar->value));
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ namespace ShlinkioTest\Shlink\Core\Config;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shlinkio\Shlink\Core\Config\EnvVars;
|
||||
|
||||
use function Functional\map;
|
||||
use function putenv;
|
||||
|
||||
class EnvVarsTest extends TestCase
|
||||
@ -58,4 +59,11 @@ class EnvVarsTest extends TestCase
|
||||
yield 'DB_DRIVER without default' => [EnvVars::DB_DRIVER, null, null];
|
||||
yield 'DB_DRIVER with default' => [EnvVars::DB_DRIVER, 'foobar', 'foobar'];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function allValuesCanBeListed(): void
|
||||
{
|
||||
$expected = map(EnvVars::cases(), static fn (EnvVars $envVar) => $envVar->value);
|
||||
self::assertEquals(EnvVars::values(), $expected);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user