Skip to content

Commit d1128c7

Browse files
committed
fix: multiline variable should be literal + should be multiline in bash with \
1 parent aae8131 commit d1128c7

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

app/Jobs/ApplicationDeploymentJob.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ private function save_environment_variables()
763763
if ($env->version === '4.0.0-beta.239') {
764764
$real_value = $env->real_value;
765765
} else {
766-
if ($env->is_literal) {
766+
if ($env->is_literal || $env->is_multiline) {
767767
$real_value = '\'' . $real_value . '\'';
768768
} else {
769769
$real_value = escapeEnvVariables($env->real_value);
@@ -804,10 +804,11 @@ private function save_environment_variables()
804804
if ($env->version === '4.0.0-beta.239') {
805805
$real_value = $env->real_value;
806806
} else {
807-
if ($env->is_literal) {
807+
if ($env->is_literal || $env->is_multiline) {
808808
$real_value = '\'' . $real_value . '\'';
809809
} else {
810810
$real_value = escapeEnvVariables($env->real_value);
811+
ray($real_value);
811812
}
812813
}
813814
$envs->push($env->key . '=' . $real_value);
@@ -1948,11 +1949,17 @@ private function generate_build_env_variables()
19481949
if ($this->pull_request_id === 0) {
19491950
foreach ($this->application->build_environment_variables as $env) {
19501951
$value = escapeshellarg($env->real_value);
1952+
if (str($value)->contains("\n") && data_get($env, 'is_multiline') === true) {
1953+
$value = str_replace("\n", "\\\n", $value);
1954+
}
19511955
$this->build_args->push("--build-arg {$env->key}={$value}");
19521956
}
19531957
} else {
19541958
foreach ($this->application->build_environment_variables_preview as $env) {
19551959
$value = escapeshellarg($env->real_value);
1960+
if (str($value)->contains("\n") && data_get($env, 'is_multiline') === true) {
1961+
$value = str_replace("\n", "\\\n", $value);
1962+
}
19561963
$this->build_args->push("--build-arg {$env->key}={$value}");
19571964
}
19581965
}
@@ -1968,10 +1975,20 @@ private function add_build_env_variables_to_dockerfile()
19681975
$dockerfile = collect(Str::of($this->saved_outputs->get('dockerfile'))->trim()->explode("\n"));
19691976
if ($this->pull_request_id === 0) {
19701977
foreach ($this->application->build_environment_variables as $env) {
1971-
$dockerfile->splice(1, 0, "ARG {$env->key}={$env->real_value}");
1978+
if (str($env->real_value)->contains("\n") && data_get($env, 'is_multiline') === true) {
1979+
$value = str_replace("\n", "\\\n", $env->real_value);
1980+
} else {
1981+
$value = $env->real_value;
1982+
}
1983+
$dockerfile->splice(1, 0, "ARG {$env->key}={$value}");
19721984
}
19731985
} else {
19741986
foreach ($this->application->build_environment_variables_preview as $env) {
1987+
if (str($env->real_value)->contains("\n") && data_get($env, 'is_multiline') === true) {
1988+
$value = str_replace("\n", "\\\n", $env->real_value);
1989+
} else {
1990+
$value = $env->real_value;
1991+
}
19751992
$dockerfile->splice(1, 0, "ARG {$env->key}={$env->real_value}");
19761993
}
19771994
}

resources/views/livewire/project/shared/environment-variable/show.blade.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ class="font-bold dark:text-warning text-coollabs">{{ $env->key }}</span>.
6363
@else
6464
<x-forms.checkbox instantSave id="env.is_build_time" label="Build Variable?" />
6565
<x-forms.checkbox instantSave id="env.is_multiline" label="Is Multiline?" />
66-
<x-forms.checkbox instantSave id="env.is_literal"
67-
helper="This means that when you use $VARIABLES in a value, it should be interpreted as the actual characters '$VARIABLES' and not as the value of a variable named VARIABLE.<br><br>Useful if you have $ sign in your value and there are some characters after it, but you would not like to interpolate it form another value. In this case, you should set this to true."
68-
label="Is Literal?" />
66+
@if (!data_get($env, 'is_multiline'))
67+
<x-forms.checkbox instantSave id="env.is_literal"
68+
helper="This means that when you use $VARIABLES in a value, it should be interpreted as the actual characters '$VARIABLES' and not as the value of a variable named VARIABLE.<br><br>Useful if you have $ sign in your value and there are some characters after it, but you would not like to interpolate it form another value. In this case, you should set this to true."
69+
label="Is Literal?" />
70+
@endif
6971
@endif
7072
@endif
7173
@endif

0 commit comments

Comments
 (0)