fix: prevent overwrite already existing env variables in services
This commit is contained in:
parent
3fc544e0b9
commit
31b0ccba99
@ -313,7 +313,12 @@ public function parse(bool $isNew = false): Collection
|
|||||||
$variableName = Str::of(replaceVariables(Str::of($value)));
|
$variableName = Str::of(replaceVariables(Str::of($value)));
|
||||||
$generatedValue = null;
|
$generatedValue = null;
|
||||||
if ($variableName->startsWith('SERVICE_USER')) {
|
if ($variableName->startsWith('SERVICE_USER')) {
|
||||||
|
$variableDefined = EnvironmentVariable::whereServiceId($this->id)->where('key', $variableName->value())->first();
|
||||||
|
if (!$variableDefined) {
|
||||||
$generatedValue = Str::random(10);
|
$generatedValue = Str::random(10);
|
||||||
|
} else {
|
||||||
|
$generatedValue = $variableDefined->value;
|
||||||
|
}
|
||||||
if (!$envs->has($variableName->value())) {
|
if (!$envs->has($variableName->value())) {
|
||||||
$envs->put($variableName->value(), $generatedValue);
|
$envs->put($variableName->value(), $generatedValue);
|
||||||
EnvironmentVariable::updateOrCreate([
|
EnvironmentVariable::updateOrCreate([
|
||||||
@ -327,7 +332,12 @@ public function parse(bool $isNew = false): Collection
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
} else if ($variableName->startsWith('SERVICE_PASSWORD')) {
|
} else if ($variableName->startsWith('SERVICE_PASSWORD')) {
|
||||||
|
$variableDefined = EnvironmentVariable::whereServiceId($this->id)->where('key', $variableName->value())->first();
|
||||||
|
if (!$variableDefined) {
|
||||||
$generatedValue = Str::password(symbols: false);
|
$generatedValue = Str::password(symbols: false);
|
||||||
|
} else {
|
||||||
|
$generatedValue = $variableDefined->value;
|
||||||
|
}
|
||||||
if (!$envs->has($variableName->value())) {
|
if (!$envs->has($variableName->value())) {
|
||||||
$envs->put($variableName->value(), $generatedValue);
|
$envs->put($variableName->value(), $generatedValue);
|
||||||
EnvironmentVariable::updateOrCreate([
|
EnvironmentVariable::updateOrCreate([
|
||||||
|
Loading…
Reference in New Issue
Block a user