feat: literal env variables
This commit is contained in:
parent
cbd2580736
commit
5b36f07493
@ -1129,7 +1129,6 @@ private function generate_compose_file()
|
|||||||
$persistent_storages = $this->generate_local_persistent_volumes();
|
$persistent_storages = $this->generate_local_persistent_volumes();
|
||||||
$volume_names = $this->generate_local_persistent_volumes_only_volume_names();
|
$volume_names = $this->generate_local_persistent_volumes_only_volume_names();
|
||||||
$environment_variables = $this->generate_environment_variables($ports);
|
$environment_variables = $this->generate_environment_variables($ports);
|
||||||
|
|
||||||
if (data_get($this->application, 'custom_labels')) {
|
if (data_get($this->application, 'custom_labels')) {
|
||||||
$this->application->parseContainerLabels();
|
$this->application->parseContainerLabels();
|
||||||
$labels = collect(preg_split("/\r\n|\n|\r/", base64_decode($this->application->custom_labels)));
|
$labels = collect(preg_split("/\r\n|\n|\r/", base64_decode($this->application->custom_labels)));
|
||||||
@ -1419,6 +1418,9 @@ private function generate_environment_variables($ports)
|
|||||||
} else {
|
} else {
|
||||||
$real_value = escapeEnvVariables($env->real_value);
|
$real_value = escapeEnvVariables($env->real_value);
|
||||||
}
|
}
|
||||||
|
if ($env->is_literal) {
|
||||||
|
$real_value = escapeDollarSign($real_value);
|
||||||
|
}
|
||||||
$environment_variables->push("$env->key=$real_value");
|
$environment_variables->push("$env->key=$real_value");
|
||||||
}
|
}
|
||||||
foreach ($this->application->nixpacks_environment_variables as $env) {
|
foreach ($this->application->nixpacks_environment_variables as $env) {
|
||||||
@ -1427,6 +1429,9 @@ private function generate_environment_variables($ports)
|
|||||||
} else {
|
} else {
|
||||||
$real_value = escapeEnvVariables($env->real_value);
|
$real_value = escapeEnvVariables($env->real_value);
|
||||||
}
|
}
|
||||||
|
if ($env->is_literal) {
|
||||||
|
$real_value = escapeDollarSign($real_value);
|
||||||
|
}
|
||||||
$environment_variables->push("$env->key=$real_value");
|
$environment_variables->push("$env->key=$real_value");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1436,6 +1441,9 @@ private function generate_environment_variables($ports)
|
|||||||
} else {
|
} else {
|
||||||
$real_value = escapeEnvVariables($env->real_value);
|
$real_value = escapeEnvVariables($env->real_value);
|
||||||
}
|
}
|
||||||
|
if ($env->is_literal) {
|
||||||
|
$real_value = escapeDollarSign($real_value);
|
||||||
|
}
|
||||||
$environment_variables->push("$env->key=$real_value");
|
$environment_variables->push("$env->key=$real_value");
|
||||||
}
|
}
|
||||||
foreach ($this->application->nixpacks_environment_variables_preview as $env) {
|
foreach ($this->application->nixpacks_environment_variables_preview as $env) {
|
||||||
@ -1444,6 +1452,9 @@ private function generate_environment_variables($ports)
|
|||||||
} else {
|
} else {
|
||||||
$real_value = escapeEnvVariables($env->real_value);
|
$real_value = escapeEnvVariables($env->real_value);
|
||||||
}
|
}
|
||||||
|
if ($env->is_literal) {
|
||||||
|
$real_value = escapeDollarSign($real_value);
|
||||||
|
}
|
||||||
$environment_variables->push("$env->key=$real_value");
|
$environment_variables->push("$env->key=$real_value");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ public function saveKey($data)
|
|||||||
'key' => $data['key'],
|
'key' => $data['key'],
|
||||||
'value' => $data['value'],
|
'value' => $data['value'],
|
||||||
'is_multiline' => $data['is_multiline'],
|
'is_multiline' => $data['is_multiline'],
|
||||||
|
'is_literal' => $data['is_literal'],
|
||||||
'type' => 'project',
|
'type' => 'project',
|
||||||
'team_id' => currentTeam()->id,
|
'team_id' => currentTeam()->id,
|
||||||
]);
|
]);
|
||||||
|
@ -29,6 +29,7 @@ public function saveKey($data)
|
|||||||
'key' => $data['key'],
|
'key' => $data['key'],
|
||||||
'value' => $data['value'],
|
'value' => $data['value'],
|
||||||
'is_multiline' => $data['is_multiline'],
|
'is_multiline' => $data['is_multiline'],
|
||||||
|
'is_literal' => $data['is_literal'],
|
||||||
'type' => 'environment',
|
'type' => 'environment',
|
||||||
'team_id' => currentTeam()->id,
|
'team_id' => currentTeam()->id,
|
||||||
]);
|
]);
|
||||||
|
@ -7,11 +7,13 @@
|
|||||||
class Add extends Component
|
class Add extends Component
|
||||||
{
|
{
|
||||||
public $parameters;
|
public $parameters;
|
||||||
|
public bool $shared = false;
|
||||||
public bool $is_preview = false;
|
public bool $is_preview = false;
|
||||||
public string $key;
|
public string $key;
|
||||||
public ?string $value = null;
|
public ?string $value = null;
|
||||||
public bool $is_build_time = false;
|
public bool $is_build_time = false;
|
||||||
public bool $is_multiline = false;
|
public bool $is_multiline = false;
|
||||||
|
public bool $is_literal = false;
|
||||||
|
|
||||||
protected $listeners = ['clearAddEnv' => 'clear'];
|
protected $listeners = ['clearAddEnv' => 'clear'];
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
@ -19,12 +21,14 @@ class Add extends Component
|
|||||||
'value' => 'nullable',
|
'value' => 'nullable',
|
||||||
'is_build_time' => 'required|boolean',
|
'is_build_time' => 'required|boolean',
|
||||||
'is_multiline' => 'required|boolean',
|
'is_multiline' => 'required|boolean',
|
||||||
|
'is_literal' => 'required|boolean',
|
||||||
];
|
];
|
||||||
protected $validationAttributes = [
|
protected $validationAttributes = [
|
||||||
'key' => 'key',
|
'key' => 'key',
|
||||||
'value' => 'value',
|
'value' => 'value',
|
||||||
'is_build_time' => 'build',
|
'is_build_time' => 'build',
|
||||||
'is_multiline' => 'multiline',
|
'is_multiline' => 'multiline',
|
||||||
|
'is_literal' => 'literal',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
@ -47,6 +51,7 @@ public function submit()
|
|||||||
'value' => $this->value,
|
'value' => $this->value,
|
||||||
'is_build_time' => $this->is_build_time,
|
'is_build_time' => $this->is_build_time,
|
||||||
'is_multiline' => $this->is_multiline,
|
'is_multiline' => $this->is_multiline,
|
||||||
|
'is_literal' => $this->is_literal,
|
||||||
'is_preview' => $this->is_preview,
|
'is_preview' => $this->is_preview,
|
||||||
]);
|
]);
|
||||||
$this->clear();
|
$this->clear();
|
||||||
@ -58,5 +63,6 @@ public function clear()
|
|||||||
$this->value = '';
|
$this->value = '';
|
||||||
$this->is_build_time = false;
|
$this->is_build_time = false;
|
||||||
$this->is_multiline = false;
|
$this->is_multiline = false;
|
||||||
|
$this->is_literal = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ class Show extends Component
|
|||||||
'env.value' => 'nullable',
|
'env.value' => 'nullable',
|
||||||
'env.is_build_time' => 'required|boolean',
|
'env.is_build_time' => 'required|boolean',
|
||||||
'env.is_multiline' => 'required|boolean',
|
'env.is_multiline' => 'required|boolean',
|
||||||
|
'env.is_literal' => 'required|boolean',
|
||||||
'env.is_shown_once' => 'required|boolean',
|
'env.is_shown_once' => 'required|boolean',
|
||||||
'env.real_value' => 'nullable',
|
'env.real_value' => 'nullable',
|
||||||
];
|
];
|
||||||
@ -30,6 +31,7 @@ class Show extends Component
|
|||||||
'env.value' => 'Value',
|
'env.value' => 'Value',
|
||||||
'env.is_build_time' => 'Build Time',
|
'env.is_build_time' => 'Build Time',
|
||||||
'env.is_multiline' => 'Multiline',
|
'env.is_multiline' => 'Multiline',
|
||||||
|
'env.is_literal' => 'Literal',
|
||||||
'env.is_shown_once' => 'Shown Once',
|
'env.is_shown_once' => 'Shown Once',
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -41,6 +43,7 @@ public function mount()
|
|||||||
$this->modalId = new Cuid2(7);
|
$this->modalId = new Cuid2(7);
|
||||||
$this->parameters = get_route_parameters();
|
$this->parameters = get_route_parameters();
|
||||||
$this->checkEnvs();
|
$this->checkEnvs();
|
||||||
|
ray($this->env);
|
||||||
}
|
}
|
||||||
public function checkEnvs()
|
public function checkEnvs()
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@ public function saveKey($data)
|
|||||||
'key' => $data['key'],
|
'key' => $data['key'],
|
||||||
'value' => $data['value'],
|
'value' => $data['value'],
|
||||||
'is_multiline' => $data['is_multiline'],
|
'is_multiline' => $data['is_multiline'],
|
||||||
|
'is_literal' => $data['is_literal'],
|
||||||
'type' => 'team',
|
'type' => 'team',
|
||||||
'team_id' => currentTeam()->id,
|
'team_id' => currentTeam()->id,
|
||||||
]);
|
]);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class SharedEnvironmentVariable extends Model
|
class SharedEnvironmentVariable extends Model
|
||||||
|
@ -586,3 +586,9 @@ function escapeEnvVariables($value)
|
|||||||
$replace = array("\\\\", "\\r", "\\t", "\\0", '\"', "\'");
|
$replace = array("\\\\", "\\r", "\\t", "\\0", '\"', "\'");
|
||||||
return str_replace($search, $replace, $value);
|
return str_replace($search, $replace, $value);
|
||||||
}
|
}
|
||||||
|
function escapeDollarSign($value)
|
||||||
|
{
|
||||||
|
$search = array('$');
|
||||||
|
$replace = array('$$');
|
||||||
|
return str_replace($search, $replace, $value);
|
||||||
|
}
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('environment_variables', function (Blueprint $table) {
|
||||||
|
$table->boolean('is_literal')->default(false);
|
||||||
|
});
|
||||||
|
Schema::table('shared_environment_variables', function (Blueprint $table) {
|
||||||
|
$table->boolean('is_literal')->default(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('environment_variables', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('is_literal');
|
||||||
|
});
|
||||||
|
Schema::table('shared_environment_variables', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('is_literal');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@ -17,7 +17,7 @@
|
|||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<h2>Shared Variables</h2>
|
<h2>Shared Variables</h2>
|
||||||
<x-modal-input buttonTitle="+ Add" title="New Shared Variable">
|
<x-modal-input buttonTitle="+ Add" title="New Shared Variable">
|
||||||
<livewire:project.shared.environment-variable.add />
|
<livewire:project.shared.environment-variable.add :shared="true" />
|
||||||
</x-modal-input>
|
</x-modal-input>
|
||||||
</div>
|
</div>
|
||||||
<div class="pb-4 lg:flex lg:gap-1">
|
<div class="pb-4 lg:flex lg:gap-1">
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
<div class="flex gap-2 pt-10">
|
<div class="flex gap-2 pt-10">
|
||||||
<h2>Shared Variables</h2>
|
<h2>Shared Variables</h2>
|
||||||
<x-modal-input buttonTitle="+ Add" title="New Shared Variable">
|
<x-modal-input buttonTitle="+ Add" title="New Shared Variable">
|
||||||
<livewire:project.shared.environment-variable.add />
|
<livewire:project.shared.environment-variable.add :shared="true" />
|
||||||
</x-modal-input>
|
</x-modal-input>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2 pb-4">You can use these variables anywhere with <span class="dark:text-warning text-coollabs">@{{environment.VARIABLENAME}}</span><x-helper
|
<div class="flex items-center gap-2 pb-4">You can use these variables anywhere with <span class="dark:text-warning text-coollabs">@{{environment.VARIABLENAME}}</span><x-helper
|
||||||
|
@ -7,6 +7,11 @@
|
|||||||
<x-forms.checkbox id="is_build_time" label="Build Variable?" />
|
<x-forms.checkbox id="is_build_time" label="Build Variable?" />
|
||||||
@endif
|
@endif
|
||||||
<x-forms.checkbox id="is_multiline" label="Is Multiline?" />
|
<x-forms.checkbox id="is_multiline" label="Is Multiline?" />
|
||||||
|
@if (!$shared)
|
||||||
|
<x-forms.checkbox id="is_literal"
|
||||||
|
helper="This means that when you use $VARIABLES, 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."
|
||||||
|
label="Is Literal?" />
|
||||||
|
@endif
|
||||||
<x-forms.button type="submit" @click="slideOverOpen=false">
|
<x-forms.button type="submit" @click="slideOverOpen=false">
|
||||||
Save
|
Save
|
||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
|
@ -45,9 +45,19 @@ class="font-bold dark:text-warning text-coollabs">{{ $env->key }}</span>.
|
|||||||
@else
|
@else
|
||||||
@if ($env->is_shared)
|
@if ($env->is_shared)
|
||||||
<x-forms.checkbox instantSave id="env.is_build_time" label="Build Variable?" />
|
<x-forms.checkbox instantSave id="env.is_build_time" label="Build Variable?" />
|
||||||
|
<x-forms.checkbox instantSave id="env.is_literal"
|
||||||
|
helper="This means that when you use $VARIABLES, 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."
|
||||||
|
label="Is Literal?" />
|
||||||
@else
|
@else
|
||||||
<x-forms.checkbox instantSave id="env.is_multiline" label="Is Multiline?" />
|
@if ($type === 'team' || $type === 'environment' || $type === 'project')
|
||||||
<x-forms.checkbox instantSave id="env.is_build_time" label="Build Variable?" />
|
<x-forms.checkbox instantSave id="env.is_multiline" label="Is Multiline?" />
|
||||||
|
@else
|
||||||
|
<x-forms.checkbox instantSave id="env.is_build_time" label="Build Variable?" />
|
||||||
|
<x-forms.checkbox instantSave id="env.is_multiline" label="Is Multiline?" />
|
||||||
|
<x-forms.checkbox instantSave id="env.is_literal"
|
||||||
|
helper="This means that when you use $VARIABLES, 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."
|
||||||
|
label="Is Literal?" />
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
<div class="flex-1"></div>
|
<div class="flex-1"></div>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<h2>Shared Variables</h2>
|
<h2>Shared Variables</h2>
|
||||||
<x-modal-input buttonTitle="+ Add" title="New Shared Variable">
|
<x-modal-input buttonTitle="+ Add" title="New Shared Variable">
|
||||||
<livewire:project.shared.environment-variable.add />
|
<livewire:project.shared.environment-variable.add :shared="true" />
|
||||||
</x-modal-input>
|
</x-modal-input>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2 pb-4">You can use these variables anywhere with <span
|
<div class="flex items-center gap-2 pb-4">You can use these variables anywhere with <span
|
||||||
|
Loading…
Reference in New Issue
Block a user