mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-21 20:27:14 +03:00
Update to shlink-config 3.2.1, which fixes skipping config options with null value
This commit is contained in:
parent
aef04af4f0
commit
4b7b530f49
3 changed files with 35 additions and 18 deletions
17
CHANGELOG.md
17
CHANGELOG.md
|
@ -4,6 +4,23 @@ 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).
|
||||
|
||||
## [4.2.3] - 2024-10-17
|
||||
### Added
|
||||
* *Nothing*
|
||||
|
||||
### Changed
|
||||
* *Nothing*
|
||||
|
||||
### Deprecated
|
||||
* *Nothing*
|
||||
|
||||
### Removed
|
||||
* *Nothing*
|
||||
|
||||
### Fixed
|
||||
* [#2225](https://github.com/shlinkio/shlink/issues/2225) Fix regression introduced in v4.2.2, making config options with `null` value to be promoted as env vars with value `''`, instead of being skipped.
|
||||
|
||||
|
||||
## [4.2.2] - 2024-10-14
|
||||
### Added
|
||||
* *Nothing*
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
"ramsey/uuid": "^4.7",
|
||||
"shlinkio/doctrine-specification": "^2.1.1",
|
||||
"shlinkio/shlink-common": "^6.3",
|
||||
"shlinkio/shlink-config": "^3.2",
|
||||
"shlinkio/shlink-config": "^3.2.1",
|
||||
"shlinkio/shlink-event-dispatcher": "^4.1",
|
||||
"shlinkio/shlink-importer": "^5.3.2",
|
||||
"shlinkio/shlink-installer": "^9.2",
|
||||
|
|
|
@ -97,6 +97,23 @@ enum EnvVars: string
|
|||
return env($this->value) ?? $this->loadFromFileEnv() ?? $this->defaultValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an equivalent environment variable exists with the `_FILE` suffix. If so, it loads its value as a file,
|
||||
* reads it, and returns its contents.
|
||||
* This is useful when loading Shlink with docker compose and using secrets.
|
||||
* See https://docs.docker.com/compose/use-secrets/
|
||||
*/
|
||||
private function loadFromFileEnv(): string|int|bool|null
|
||||
{
|
||||
$file = env(sprintf('%s_FILE', $this->value));
|
||||
if ($file === null || ! is_file($file)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$content = file_get_contents($file);
|
||||
return $content ? parseEnvVar($content) : null;
|
||||
}
|
||||
|
||||
private function defaultValue(): string|int|bool|null
|
||||
{
|
||||
return match ($this) {
|
||||
|
@ -153,23 +170,6 @@ enum EnvVars: string
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an equivalent environment variable exists with the `_FILE` suffix. If so, it loads its value as a file,
|
||||
* reads it, and returns its contents.
|
||||
* This is useful when loading Shlink with docker compose and using secrets.
|
||||
* See https://docs.docker.com/compose/use-secrets/
|
||||
*/
|
||||
private function loadFromFileEnv(): string|int|bool|null
|
||||
{
|
||||
$file = env(sprintf('%s_FILE', $this->value));
|
||||
if ($file === null || ! is_file($file)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$content = file_get_contents($file);
|
||||
return $content ? parseEnvVar($content) : null;
|
||||
}
|
||||
|
||||
public function existsInEnv(): bool
|
||||
{
|
||||
return $this->loadFromEnv() !== null;
|
||||
|
|
Loading…
Reference in a new issue