feat(environment): introduce 'is_buildtime_only' attribute to environment variables for improved build-time configuration
This commit is contained in:
@@ -2532,6 +2532,9 @@ class ApplicationsController extends Controller
|
|||||||
if ($env->is_shown_once != $request->is_shown_once) {
|
if ($env->is_shown_once != $request->is_shown_once) {
|
||||||
$env->is_shown_once = $request->is_shown_once;
|
$env->is_shown_once = $request->is_shown_once;
|
||||||
}
|
}
|
||||||
|
if ($request->has('is_buildtime_only') && $env->is_buildtime_only != $request->is_buildtime_only) {
|
||||||
|
$env->is_buildtime_only = $request->is_buildtime_only;
|
||||||
|
}
|
||||||
$env->save();
|
$env->save();
|
||||||
|
|
||||||
return response()->json($this->removeSensitiveData($env))->setStatusCode(201);
|
return response()->json($this->removeSensitiveData($env))->setStatusCode(201);
|
||||||
@@ -2556,6 +2559,9 @@ class ApplicationsController extends Controller
|
|||||||
if ($env->is_shown_once != $request->is_shown_once) {
|
if ($env->is_shown_once != $request->is_shown_once) {
|
||||||
$env->is_shown_once = $request->is_shown_once;
|
$env->is_shown_once = $request->is_shown_once;
|
||||||
}
|
}
|
||||||
|
if ($request->has('is_buildtime_only') && $env->is_buildtime_only != $request->is_buildtime_only) {
|
||||||
|
$env->is_buildtime_only = $request->is_buildtime_only;
|
||||||
|
}
|
||||||
$env->save();
|
$env->save();
|
||||||
|
|
||||||
return response()->json($this->removeSensitiveData($env))->setStatusCode(201);
|
return response()->json($this->removeSensitiveData($env))->setStatusCode(201);
|
||||||
@@ -2717,6 +2723,9 @@ class ApplicationsController extends Controller
|
|||||||
if ($env->is_shown_once != $item->get('is_shown_once')) {
|
if ($env->is_shown_once != $item->get('is_shown_once')) {
|
||||||
$env->is_shown_once = $item->get('is_shown_once');
|
$env->is_shown_once = $item->get('is_shown_once');
|
||||||
}
|
}
|
||||||
|
if ($item->has('is_buildtime_only') && $env->is_buildtime_only != $item->get('is_buildtime_only')) {
|
||||||
|
$env->is_buildtime_only = $item->get('is_buildtime_only');
|
||||||
|
}
|
||||||
$env->save();
|
$env->save();
|
||||||
} else {
|
} else {
|
||||||
$env = $application->environment_variables()->create([
|
$env = $application->environment_variables()->create([
|
||||||
@@ -2726,6 +2735,7 @@ class ApplicationsController extends Controller
|
|||||||
'is_literal' => $is_literal,
|
'is_literal' => $is_literal,
|
||||||
'is_multiline' => $is_multi_line,
|
'is_multiline' => $is_multi_line,
|
||||||
'is_shown_once' => $is_shown_once,
|
'is_shown_once' => $is_shown_once,
|
||||||
|
'is_buildtime_only' => $item->get('is_buildtime_only', false),
|
||||||
'resourceable_type' => get_class($application),
|
'resourceable_type' => get_class($application),
|
||||||
'resourceable_id' => $application->id,
|
'resourceable_id' => $application->id,
|
||||||
]);
|
]);
|
||||||
@@ -2743,6 +2753,9 @@ class ApplicationsController extends Controller
|
|||||||
if ($env->is_shown_once != $item->get('is_shown_once')) {
|
if ($env->is_shown_once != $item->get('is_shown_once')) {
|
||||||
$env->is_shown_once = $item->get('is_shown_once');
|
$env->is_shown_once = $item->get('is_shown_once');
|
||||||
}
|
}
|
||||||
|
if ($item->has('is_buildtime_only') && $env->is_buildtime_only != $item->get('is_buildtime_only')) {
|
||||||
|
$env->is_buildtime_only = $item->get('is_buildtime_only');
|
||||||
|
}
|
||||||
$env->save();
|
$env->save();
|
||||||
} else {
|
} else {
|
||||||
$env = $application->environment_variables()->create([
|
$env = $application->environment_variables()->create([
|
||||||
@@ -2752,6 +2765,7 @@ class ApplicationsController extends Controller
|
|||||||
'is_literal' => $is_literal,
|
'is_literal' => $is_literal,
|
||||||
'is_multiline' => $is_multi_line,
|
'is_multiline' => $is_multi_line,
|
||||||
'is_shown_once' => $is_shown_once,
|
'is_shown_once' => $is_shown_once,
|
||||||
|
'is_buildtime_only' => $item->get('is_buildtime_only', false),
|
||||||
'resourceable_type' => get_class($application),
|
'resourceable_type' => get_class($application),
|
||||||
'resourceable_id' => $application->id,
|
'resourceable_id' => $application->id,
|
||||||
]);
|
]);
|
||||||
@@ -2890,6 +2904,7 @@ class ApplicationsController extends Controller
|
|||||||
'is_literal' => $request->is_literal ?? false,
|
'is_literal' => $request->is_literal ?? false,
|
||||||
'is_multiline' => $request->is_multiline ?? false,
|
'is_multiline' => $request->is_multiline ?? false,
|
||||||
'is_shown_once' => $request->is_shown_once ?? false,
|
'is_shown_once' => $request->is_shown_once ?? false,
|
||||||
|
'is_buildtime_only' => $request->is_buildtime_only ?? false,
|
||||||
'resourceable_type' => get_class($application),
|
'resourceable_type' => get_class($application),
|
||||||
'resourceable_id' => $application->id,
|
'resourceable_id' => $application->id,
|
||||||
]);
|
]);
|
||||||
@@ -2912,6 +2927,7 @@ class ApplicationsController extends Controller
|
|||||||
'is_literal' => $request->is_literal ?? false,
|
'is_literal' => $request->is_literal ?? false,
|
||||||
'is_multiline' => $request->is_multiline ?? false,
|
'is_multiline' => $request->is_multiline ?? false,
|
||||||
'is_shown_once' => $request->is_shown_once ?? false,
|
'is_shown_once' => $request->is_shown_once ?? false,
|
||||||
|
'is_buildtime_only' => $request->is_buildtime_only ?? false,
|
||||||
'resourceable_type' => get_class($application),
|
'resourceable_type' => get_class($application),
|
||||||
'resourceable_id' => $application->id,
|
'resourceable_id' => $application->id,
|
||||||
]);
|
]);
|
||||||
|
@@ -911,7 +911,11 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
});
|
});
|
||||||
if ($this->pull_request_id === 0) {
|
if ($this->pull_request_id === 0) {
|
||||||
$this->env_filename = '.env';
|
$this->env_filename = '.env';
|
||||||
foreach ($sorted_environment_variables as $env) {
|
// Filter out buildtime-only variables from runtime environment
|
||||||
|
$runtime_environment_variables = $sorted_environment_variables->filter(function ($env) {
|
||||||
|
return ! $env->is_buildtime_only;
|
||||||
|
});
|
||||||
|
foreach ($runtime_environment_variables as $env) {
|
||||||
$envs->push($env->key.'='.$env->real_value);
|
$envs->push($env->key.'='.$env->real_value);
|
||||||
}
|
}
|
||||||
// Add PORT if not exists, use the first port as default
|
// Add PORT if not exists, use the first port as default
|
||||||
@@ -955,7 +959,11 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->env_filename = '.env';
|
$this->env_filename = '.env';
|
||||||
foreach ($sorted_environment_variables_preview as $env) {
|
// Filter out buildtime-only variables from runtime environment for preview
|
||||||
|
$runtime_environment_variables_preview = $sorted_environment_variables_preview->filter(function ($env) {
|
||||||
|
return ! $env->is_buildtime_only;
|
||||||
|
});
|
||||||
|
foreach ($runtime_environment_variables_preview as $env) {
|
||||||
$envs->push($env->key.'='.$env->real_value);
|
$envs->push($env->key.'='.$env->real_value);
|
||||||
}
|
}
|
||||||
// Add PORT if not exists, use the first port as default
|
// Add PORT if not exists, use the first port as default
|
||||||
|
@@ -23,6 +23,8 @@ class Add extends Component
|
|||||||
|
|
||||||
public bool $is_literal = false;
|
public bool $is_literal = false;
|
||||||
|
|
||||||
|
public bool $is_buildtime_only = false;
|
||||||
|
|
||||||
protected $listeners = ['clearAddEnv' => 'clear'];
|
protected $listeners = ['clearAddEnv' => 'clear'];
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
@@ -30,6 +32,7 @@ class Add extends Component
|
|||||||
'value' => 'nullable',
|
'value' => 'nullable',
|
||||||
'is_multiline' => 'required|boolean',
|
'is_multiline' => 'required|boolean',
|
||||||
'is_literal' => 'required|boolean',
|
'is_literal' => 'required|boolean',
|
||||||
|
'is_buildtime_only' => 'required|boolean',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $validationAttributes = [
|
protected $validationAttributes = [
|
||||||
@@ -37,6 +40,7 @@ class Add extends Component
|
|||||||
'value' => 'value',
|
'value' => 'value',
|
||||||
'is_multiline' => 'multiline',
|
'is_multiline' => 'multiline',
|
||||||
'is_literal' => 'literal',
|
'is_literal' => 'literal',
|
||||||
|
'is_buildtime_only' => 'buildtime only',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
@@ -52,6 +56,7 @@ class Add extends Component
|
|||||||
'value' => $this->value,
|
'value' => $this->value,
|
||||||
'is_multiline' => $this->is_multiline,
|
'is_multiline' => $this->is_multiline,
|
||||||
'is_literal' => $this->is_literal,
|
'is_literal' => $this->is_literal,
|
||||||
|
'is_buildtime_only' => $this->is_buildtime_only,
|
||||||
'is_preview' => $this->is_preview,
|
'is_preview' => $this->is_preview,
|
||||||
]);
|
]);
|
||||||
$this->clear();
|
$this->clear();
|
||||||
@@ -63,5 +68,6 @@ class Add extends Component
|
|||||||
$this->value = '';
|
$this->value = '';
|
||||||
$this->is_multiline = false;
|
$this->is_multiline = false;
|
||||||
$this->is_literal = false;
|
$this->is_literal = false;
|
||||||
|
$this->is_buildtime_only = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -214,6 +214,7 @@ class All extends Component
|
|||||||
$environment->value = $data['value'];
|
$environment->value = $data['value'];
|
||||||
$environment->is_multiline = $data['is_multiline'] ?? false;
|
$environment->is_multiline = $data['is_multiline'] ?? false;
|
||||||
$environment->is_literal = $data['is_literal'] ?? false;
|
$environment->is_literal = $data['is_literal'] ?? false;
|
||||||
|
$environment->is_buildtime_only = $data['is_buildtime_only'] ?? false;
|
||||||
$environment->is_preview = $data['is_preview'] ?? false;
|
$environment->is_preview = $data['is_preview'] ?? false;
|
||||||
$environment->resourceable_id = $this->resource->id;
|
$environment->resourceable_id = $this->resource->id;
|
||||||
$environment->resourceable_type = $this->resource->getMorphClass();
|
$environment->resourceable_type = $this->resource->getMorphClass();
|
||||||
|
@@ -38,6 +38,8 @@ class Show extends Component
|
|||||||
|
|
||||||
public bool $is_shown_once = false;
|
public bool $is_shown_once = false;
|
||||||
|
|
||||||
|
public bool $is_buildtime_only = false;
|
||||||
|
|
||||||
public bool $is_required = false;
|
public bool $is_required = false;
|
||||||
|
|
||||||
public bool $is_really_required = false;
|
public bool $is_really_required = false;
|
||||||
@@ -56,6 +58,7 @@ class Show extends Component
|
|||||||
'is_multiline' => 'required|boolean',
|
'is_multiline' => 'required|boolean',
|
||||||
'is_literal' => 'required|boolean',
|
'is_literal' => 'required|boolean',
|
||||||
'is_shown_once' => 'required|boolean',
|
'is_shown_once' => 'required|boolean',
|
||||||
|
'is_buildtime_only' => 'required|boolean',
|
||||||
'real_value' => 'nullable',
|
'real_value' => 'nullable',
|
||||||
'is_required' => 'required|boolean',
|
'is_required' => 'required|boolean',
|
||||||
];
|
];
|
||||||
@@ -99,6 +102,7 @@ class Show extends Component
|
|||||||
} else {
|
} else {
|
||||||
$this->validate();
|
$this->validate();
|
||||||
$this->env->is_required = $this->is_required;
|
$this->env->is_required = $this->is_required;
|
||||||
|
$this->env->is_buildtime_only = $this->is_buildtime_only;
|
||||||
$this->env->is_shared = $this->is_shared;
|
$this->env->is_shared = $this->is_shared;
|
||||||
}
|
}
|
||||||
$this->env->key = $this->key;
|
$this->env->key = $this->key;
|
||||||
@@ -113,6 +117,7 @@ class Show extends Component
|
|||||||
$this->is_multiline = $this->env->is_multiline;
|
$this->is_multiline = $this->env->is_multiline;
|
||||||
$this->is_literal = $this->env->is_literal;
|
$this->is_literal = $this->env->is_literal;
|
||||||
$this->is_shown_once = $this->env->is_shown_once;
|
$this->is_shown_once = $this->env->is_shown_once;
|
||||||
|
$this->is_buildtime_only = $this->env->is_buildtime_only ?? false;
|
||||||
$this->is_required = $this->env->is_required ?? false;
|
$this->is_required = $this->env->is_required ?? false;
|
||||||
$this->is_really_required = $this->env->is_really_required ?? false;
|
$this->is_really_required = $this->env->is_really_required ?? false;
|
||||||
$this->is_shared = $this->env->is_shared ?? false;
|
$this->is_shared = $this->env->is_shared ?? false;
|
||||||
|
@@ -17,6 +17,7 @@ use OpenApi\Attributes as OA;
|
|||||||
'is_literal' => ['type' => 'boolean'],
|
'is_literal' => ['type' => 'boolean'],
|
||||||
'is_multiline' => ['type' => 'boolean'],
|
'is_multiline' => ['type' => 'boolean'],
|
||||||
'is_preview' => ['type' => 'boolean'],
|
'is_preview' => ['type' => 'boolean'],
|
||||||
|
'is_buildtime_only' => ['type' => 'boolean'],
|
||||||
'is_shared' => ['type' => 'boolean'],
|
'is_shared' => ['type' => 'boolean'],
|
||||||
'is_shown_once' => ['type' => 'boolean'],
|
'is_shown_once' => ['type' => 'boolean'],
|
||||||
'key' => ['type' => 'string'],
|
'key' => ['type' => 'string'],
|
||||||
@@ -36,6 +37,7 @@ class EnvironmentVariable extends BaseModel
|
|||||||
'value' => 'encrypted',
|
'value' => 'encrypted',
|
||||||
'is_multiline' => 'boolean',
|
'is_multiline' => 'boolean',
|
||||||
'is_preview' => 'boolean',
|
'is_preview' => 'boolean',
|
||||||
|
'is_buildtime_only' => 'boolean',
|
||||||
'version' => 'string',
|
'version' => 'string',
|
||||||
'resourceable_type' => 'string',
|
'resourceable_type' => 'string',
|
||||||
'resourceable_id' => 'integer',
|
'resourceable_id' => 'integer',
|
||||||
|
@@ -0,0 +1,28 @@
|
|||||||
|
<?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_buildtime_only')->default(false)->after('is_preview');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('environment_variables', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('is_buildtime_only');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@@ -5,6 +5,9 @@
|
|||||||
x-bind:label="$wire.is_multiline === false && 'Value'" required />
|
x-bind:label="$wire.is_multiline === false && 'Value'" required />
|
||||||
<x-forms.checkbox id="is_multiline" label="Is Multiline?" />
|
<x-forms.checkbox id="is_multiline" label="Is Multiline?" />
|
||||||
@if (!$shared)
|
@if (!$shared)
|
||||||
|
<x-forms.checkbox id="is_buildtime_only"
|
||||||
|
helper="This variable will ONLY be available during build and not in the running container. Useful for build secrets that shouldn't persist at runtime."
|
||||||
|
label="Buildtime Only?" />
|
||||||
<x-forms.checkbox id="is_literal"
|
<x-forms.checkbox id="is_literal"
|
||||||
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 from another value. In this case, you should set this to true."
|
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 from another value. In this case, you should set this to true."
|
||||||
label="Is Literal?" />
|
label="Is Literal?" />
|
||||||
|
@@ -58,6 +58,9 @@
|
|||||||
<div class="flex flex-col w-full gap-2 lg:flex-row">
|
<div class="flex flex-col w-full gap-2 lg:flex-row">
|
||||||
@if (!$is_redis_credential)
|
@if (!$is_redis_credential)
|
||||||
@if ($type === 'service')
|
@if ($type === 'service')
|
||||||
|
<x-forms.checkbox instantSave id="is_buildtime_only"
|
||||||
|
helper="This variable will ONLY be available during build and not in the running container. Useful for build secrets that shouldn't persist at runtime."
|
||||||
|
label="Buildtime Only?" />
|
||||||
<x-forms.checkbox instantSave id="is_multiline" label="Is Multiline?" />
|
<x-forms.checkbox instantSave id="is_multiline" label="Is Multiline?" />
|
||||||
<x-forms.checkbox instantSave id="is_literal"
|
<x-forms.checkbox instantSave id="is_literal"
|
||||||
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 from another value. In this case, you should set this to true."
|
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 from another value. In this case, you should set this to true."
|
||||||
@@ -71,6 +74,9 @@
|
|||||||
@if ($isSharedVariable)
|
@if ($isSharedVariable)
|
||||||
<x-forms.checkbox instantSave id="is_multiline" label="Is Multiline?" />
|
<x-forms.checkbox instantSave id="is_multiline" label="Is Multiline?" />
|
||||||
@else
|
@else
|
||||||
|
<x-forms.checkbox instantSave id="is_buildtime_only"
|
||||||
|
helper="This variable will ONLY be available during build and not in the running container. Useful for build secrets that shouldn't persist at runtime."
|
||||||
|
label="Buildtime Only?" />
|
||||||
<x-forms.checkbox instantSave id="is_multiline" label="Is Multiline?" />
|
<x-forms.checkbox instantSave id="is_multiline" label="Is Multiline?" />
|
||||||
@if ($is_multiline === false)
|
@if ($is_multiline === false)
|
||||||
<x-forms.checkbox instantSave id="is_literal"
|
<x-forms.checkbox instantSave id="is_literal"
|
||||||
@@ -114,6 +120,9 @@
|
|||||||
<div class="flex flex-col w-full gap-2 flex-wrap lg:flex-row">
|
<div class="flex flex-col w-full gap-2 flex-wrap lg:flex-row">
|
||||||
@if (!$is_redis_credential)
|
@if (!$is_redis_credential)
|
||||||
@if ($type === 'service')
|
@if ($type === 'service')
|
||||||
|
<x-forms.checkbox disabled id="is_buildtime_only"
|
||||||
|
helper="This variable will ONLY be available during build and not in the running container. Useful for build secrets that shouldn't persist at runtime."
|
||||||
|
label="Buildtime Only?" />
|
||||||
<x-forms.checkbox disabled id="is_multiline" label="Is Multiline?" />
|
<x-forms.checkbox disabled id="is_multiline" label="Is Multiline?" />
|
||||||
<x-forms.checkbox disabled id="is_literal"
|
<x-forms.checkbox disabled id="is_literal"
|
||||||
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 from another value. In this case, you should set this to true."
|
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 from another value. In this case, you should set this to true."
|
||||||
@@ -127,6 +136,9 @@
|
|||||||
@if ($isSharedVariable)
|
@if ($isSharedVariable)
|
||||||
<x-forms.checkbox disabled id="is_multiline" label="Is Multiline?" />
|
<x-forms.checkbox disabled id="is_multiline" label="Is Multiline?" />
|
||||||
@else
|
@else
|
||||||
|
<x-forms.checkbox disabled id="is_buildtime_only"
|
||||||
|
helper="This variable will ONLY be available during build and not in the running container. Useful for build secrets that shouldn't persist at runtime."
|
||||||
|
label="Buildtime Only?" />
|
||||||
<x-forms.checkbox disabled id="is_multiline" label="Is Multiline?" />
|
<x-forms.checkbox disabled id="is_multiline" label="Is Multiline?" />
|
||||||
@if ($is_multiline === false)
|
@if ($is_multiline === false)
|
||||||
<x-forms.checkbox disabled id="is_literal"
|
<x-forms.checkbox disabled id="is_literal"
|
||||||
|
Reference in New Issue
Block a user