mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-12-20 14:36:52 +00:00
Fix psalm errors in DockerActionManager env handling code
Signed-off-by: Alan Savage <3028205+asavageiv@users.noreply.github.com>
This commit is contained in:
parent
d374fd2c1c
commit
0f858dc3fe
1 changed files with 7 additions and 6 deletions
|
|
@ -475,7 +475,7 @@ readonly class DockerActionManager {
|
|||
|
||||
// Replaces placeholders in $envValue with their values.
|
||||
// E.g. "%NC_DOMAIN%:%APACHE_PORT" becomes "my.nextcloud.com:11000"
|
||||
private function replaceEnvPlaceholders($envValue) {
|
||||
private function replaceEnvPlaceholders(string $envValue): string {
|
||||
// $pattern breaks down as:
|
||||
// % - matches a literal percent sign
|
||||
// ([^%]+) - capture group that matches one or more characters that are NOT percent signs
|
||||
|
|
@ -488,16 +488,17 @@ readonly class DockerActionManager {
|
|||
if ($matchCount > 0) {
|
||||
$placeholders = $matches[0]; // ["%PLACEHOLDER1%", "%PLACEHOLDER2%", ...]
|
||||
$placeholderNames = $matches[1]; // ["PLACEHOLDER1", "PLACEHOLDER2", ...]
|
||||
$placeholderToPattern = fn($placeholder) => '/' . $placeholder . '/';
|
||||
$placeholderToPattern = fn(string $p): string => '/' . $p . '/';
|
||||
$placeholderPatterns = array_map($placeholderToPattern, $placeholders); // ["/%PLACEHOLDER1%/", ...]
|
||||
$placeholderValues = array_map([$this, 'getPlaceholderValue'], $placeholderNames); // ["val1", "val2"]
|
||||
$result = preg_replace($placeholderPatterns, $placeholderValues, $envValue);
|
||||
// Guaranteed to be non-null because we found the placeholders in the preg_match_all.
|
||||
$result = (string) preg_replace($placeholderPatterns, $placeholderValues, $envValue);
|
||||
return $result;
|
||||
}
|
||||
return $envValue;
|
||||
}
|
||||
|
||||
private function getPlaceholderValue($placeholder) {
|
||||
private function getPlaceholderValue(string $placeholder) : string {
|
||||
return match ($placeholder) {
|
||||
'NC_DOMAIN' => $this->configurationManager->GetDomain(),
|
||||
'NC_BASE_DN' => $this->configurationManager->GetBaseDN(),
|
||||
|
|
@ -530,7 +531,7 @@ readonly class DockerActionManager {
|
|||
'NEXTCLOUD_TRUSTED_CACERTS_DIR' => $this->configurationManager->GetTrustedCacertsDir(),
|
||||
'ADDITIONAL_DIRECTORIES_BACKUP' => $this->configurationManager->GetAdditionalBackupDirectoriesString() !== '' ? 'yes' : '',
|
||||
'BORGBACKUP_HOST_LOCATION' => $this->configurationManager->GetBorgBackupHostLocation(),
|
||||
'APACHE_MAX_SIZE' => $this->configurationManager->GetApacheMaxSize(),
|
||||
'APACHE_MAX_SIZE' => (string)($this->configurationManager->GetApacheMaxSize()),
|
||||
'COLLABORA_SECCOMP_POLICY' => $this->configurationManager->GetCollaboraSeccompPolicy(),
|
||||
'NEXTCLOUD_STARTUP_APPS' => $this->configurationManager->GetNextcloudStartupApps(),
|
||||
'NEXTCLOUD_ADDITIONAL_APKS' => $this->configurationManager->GetNextcloudAdditionalApks(),
|
||||
|
|
@ -546,7 +547,7 @@ readonly class DockerActionManager {
|
|||
};
|
||||
}
|
||||
|
||||
private function getSecretOrThrow($secretName) {
|
||||
private function getSecretOrThrow(string $secretName): string {
|
||||
$secret = $this->configurationManager->GetSecret($secretName);
|
||||
if ($secret === "") {
|
||||
throw new \Exception("The secret " . $secretName . " is empty. Cannot substitute its value. Please check if it is defined in secrets of containers.json.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue