Skip to content

Commit 8c024dd

Browse files
committed
chore: Update homarr service template and remove unnecessary code
1 parent d990a56 commit 8c024dd

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

bootstrap/helpers/shared.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,31 @@ function convertToArray($collection)
828828
return $collection;
829829
}
830830

831+
function parseCommandFromMagicEnvVariable(Str|string $key): Stringable
832+
{
833+
$value = str($key);
834+
$count = substr_count($value->value(), '_');
835+
if ($count === 2) {
836+
if ($value->startsWith('SERVICE_FQDN') || $value->startsWith('SERVICE_URL')) {
837+
// SERVICE_FQDN_UMAMI
838+
$command = $value->after('SERVICE_')->beforeLast('_');
839+
} else {
840+
// SERVICE_BASE64_UMAMI
841+
$command = $value->after('SERVICE_')->beforeLast('_');
842+
}
843+
}
844+
if ($count === 3) {
845+
if ($value->startsWith('SERVICE_FQDN') || $value->startsWith('SERVICE_URL')) {
846+
// SERVICE_FQDN_UMAMI_1000
847+
$command = $value->after('SERVICE_')->before('_');
848+
} else {
849+
// SERVICE_BASE64_64_UMAMI
850+
$command = $value->after('SERVICE_')->beforeLast('_');
851+
}
852+
}
853+
854+
return str($command);
855+
}
831856
function parseEnvVariable(Str|string $value)
832857
{
833858
$value = str($value);
@@ -859,6 +884,7 @@ function parseEnvVariable(Str|string $value)
859884
} else {
860885
// SERVICE_BASE64_64_UMAMI
861886
$command = $value->after('SERVICE_')->beforeLast('_');
887+
ray($command);
862888
}
863889
}
864890
}
@@ -3117,7 +3143,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
31173143
foreach ($magicEnvironments as $key => $value) {
31183144
$key = str($key);
31193145
$value = replaceVariables($value);
3120-
$command = $key->after('SERVICE_')->before('_');
3146+
$command = parseCommandFromMagicEnvVariable($key);
31213147
$found = $resource->environment_variables()->where('key', $key->value())->where($nameOfId, $resource->id)->first();
31223148
if ($found) {
31233149
continue;

0 commit comments

Comments
 (0)