feat: add readonly labels
This commit is contained in:
parent
85e1cbad53
commit
c0e88df3e8
@ -732,8 +732,10 @@ private function create_application(Request $request, $type)
|
|||||||
$application->environment_id = $environment->id;
|
$application->environment_id = $environment->id;
|
||||||
$application->save();
|
$application->save();
|
||||||
$application->refresh();
|
$application->refresh();
|
||||||
$application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
if (! $application->settings->is_container_label_readonly_enabled) {
|
||||||
$application->save();
|
$application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
||||||
|
$application->save();
|
||||||
|
}
|
||||||
$application->isConfigurationChanged(true);
|
$application->isConfigurationChanged(true);
|
||||||
|
|
||||||
if ($instantDeploy) {
|
if ($instantDeploy) {
|
||||||
@ -826,8 +828,10 @@ private function create_application(Request $request, $type)
|
|||||||
$application->source_id = $githubApp->id;
|
$application->source_id = $githubApp->id;
|
||||||
$application->save();
|
$application->save();
|
||||||
$application->refresh();
|
$application->refresh();
|
||||||
$application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
if (! $application->settings->is_container_label_readonly_enabled) {
|
||||||
$application->save();
|
$application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
||||||
|
$application->save();
|
||||||
|
}
|
||||||
$application->isConfigurationChanged(true);
|
$application->isConfigurationChanged(true);
|
||||||
|
|
||||||
if ($instantDeploy) {
|
if ($instantDeploy) {
|
||||||
@ -916,8 +920,10 @@ private function create_application(Request $request, $type)
|
|||||||
$application->environment_id = $environment->id;
|
$application->environment_id = $environment->id;
|
||||||
$application->save();
|
$application->save();
|
||||||
$application->refresh();
|
$application->refresh();
|
||||||
$application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
if (! $application->settings->is_container_label_readonly_enabled) {
|
||||||
$application->save();
|
$application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
||||||
|
$application->save();
|
||||||
|
}
|
||||||
$application->isConfigurationChanged(true);
|
$application->isConfigurationChanged(true);
|
||||||
|
|
||||||
if ($instantDeploy) {
|
if ($instantDeploy) {
|
||||||
@ -996,8 +1002,10 @@ private function create_application(Request $request, $type)
|
|||||||
$application->git_branch = 'main';
|
$application->git_branch = 'main';
|
||||||
$application->save();
|
$application->save();
|
||||||
$application->refresh();
|
$application->refresh();
|
||||||
$application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
if (! $application->settings->is_container_label_readonly_enabled) {
|
||||||
$application->save();
|
$application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
||||||
|
$application->save();
|
||||||
|
}
|
||||||
$application->isConfigurationChanged(true);
|
$application->isConfigurationChanged(true);
|
||||||
|
|
||||||
if ($instantDeploy) {
|
if ($instantDeploy) {
|
||||||
@ -1052,8 +1060,10 @@ private function create_application(Request $request, $type)
|
|||||||
$application->git_branch = 'main';
|
$application->git_branch = 'main';
|
||||||
$application->save();
|
$application->save();
|
||||||
$application->refresh();
|
$application->refresh();
|
||||||
$application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
if (! $application->settings->is_container_label_readonly_enabled) {
|
||||||
$application->save();
|
$application->custom_labels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
||||||
|
$application->save();
|
||||||
|
}
|
||||||
$application->isConfigurationChanged(true);
|
$application->isConfigurationChanged(true);
|
||||||
|
|
||||||
if ($instantDeploy) {
|
if ($instantDeploy) {
|
||||||
@ -1494,8 +1504,10 @@ public function update_by_uuid(Request $request)
|
|||||||
$fqdn = str($fqdn)->replaceEnd(',', '')->trim();
|
$fqdn = str($fqdn)->replaceEnd(',', '')->trim();
|
||||||
$fqdn = str($fqdn)->replaceStart(',', '')->trim();
|
$fqdn = str($fqdn)->replaceStart(',', '')->trim();
|
||||||
$application->fqdn = $fqdn;
|
$application->fqdn = $fqdn;
|
||||||
$customLabels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
if (! $application->settings->is_container_label_readonly_enabled) {
|
||||||
$application->custom_labels = base64_encode($customLabels);
|
$customLabels = str(implode('|coolify|', generateLabelsApplication($application)))->replace('|coolify|', "\n");
|
||||||
|
$application->custom_labels = base64_encode($customLabels);
|
||||||
|
}
|
||||||
$request->offsetUnset('domains');
|
$request->offsetUnset('domains');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1523,7 +1523,9 @@ private function generate_compose_file()
|
|||||||
$this->application->custom_labels = base64_encode($labels->implode("\n"));
|
$this->application->custom_labels = base64_encode($labels->implode("\n"));
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
} else {
|
} else {
|
||||||
$labels = collect(generateLabelsApplication($this->application, $this->preview));
|
if (! $this->application->settings->is_container_label_readonly_enabled) {
|
||||||
|
$labels = collect(generateLabelsApplication($this->application, $this->preview));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($this->pull_request_id !== 0) {
|
if ($this->pull_request_id !== 0) {
|
||||||
$labels = collect(generateLabelsApplication($this->application, $this->preview));
|
$labels = collect(generateLabelsApplication($this->application, $this->preview));
|
||||||
|
@ -84,6 +84,7 @@ class General extends Component
|
|||||||
'application.settings.is_static' => 'boolean|required',
|
'application.settings.is_static' => 'boolean|required',
|
||||||
'application.settings.is_build_server_enabled' => 'boolean|required',
|
'application.settings.is_build_server_enabled' => 'boolean|required',
|
||||||
'application.settings.is_container_label_escape_enabled' => 'boolean|required',
|
'application.settings.is_container_label_escape_enabled' => 'boolean|required',
|
||||||
|
'application.settings.is_container_label_readonly_enabled' => 'boolean|required',
|
||||||
'application.watch_paths' => 'nullable',
|
'application.watch_paths' => 'nullable',
|
||||||
'application.redirect' => 'string|required',
|
'application.redirect' => 'string|required',
|
||||||
];
|
];
|
||||||
@ -119,6 +120,7 @@ class General extends Component
|
|||||||
'application.settings.is_static' => 'Is static',
|
'application.settings.is_static' => 'Is static',
|
||||||
'application.settings.is_build_server_enabled' => 'Is build server enabled',
|
'application.settings.is_build_server_enabled' => 'Is build server enabled',
|
||||||
'application.settings.is_container_label_escape_enabled' => 'Is container label escape enabled',
|
'application.settings.is_container_label_escape_enabled' => 'Is container label escape enabled',
|
||||||
|
'application.settings.is_container_label_readonly_enabled' => 'Is container label readonly',
|
||||||
'application.watch_paths' => 'Watch paths',
|
'application.watch_paths' => 'Watch paths',
|
||||||
'application.redirect' => 'Redirect',
|
'application.redirect' => 'Redirect',
|
||||||
];
|
];
|
||||||
@ -143,7 +145,7 @@ public function mount()
|
|||||||
$this->ports_exposes = $this->application->ports_exposes;
|
$this->ports_exposes = $this->application->ports_exposes;
|
||||||
$this->is_container_label_escape_enabled = $this->application->settings->is_container_label_escape_enabled;
|
$this->is_container_label_escape_enabled = $this->application->settings->is_container_label_escape_enabled;
|
||||||
$this->customLabels = $this->application->parseContainerLabels();
|
$this->customLabels = $this->application->parseContainerLabels();
|
||||||
if (! $this->customLabels && $this->application->destination->server->proxyType() !== 'NONE') {
|
if (! $this->customLabels && $this->application->destination->server->proxyType() !== 'NONE' && ! $this->application->settings->is_container_label_readonly_enabled) {
|
||||||
$this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n");
|
$this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n");
|
||||||
$this->application->custom_labels = base64_encode($this->customLabels);
|
$this->application->custom_labels = base64_encode($this->customLabels);
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
@ -290,6 +292,9 @@ public function getWildcardDomain()
|
|||||||
|
|
||||||
public function resetDefaultLabels()
|
public function resetDefaultLabels()
|
||||||
{
|
{
|
||||||
|
if ($this->application->settings->is_container_label_readonly_enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n");
|
$this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n");
|
||||||
$this->ports_exposes = $this->application->ports_exposes;
|
$this->ports_exposes = $this->application->ports_exposes;
|
||||||
$this->is_container_label_escape_enabled = $this->application->settings->is_container_label_escape_enabled;
|
$this->is_container_label_escape_enabled = $this->application->settings->is_container_label_escape_enabled;
|
||||||
@ -350,7 +355,7 @@ public function submit($showToaster = true)
|
|||||||
$this->checkFqdns();
|
$this->checkFqdns();
|
||||||
|
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
if (! $this->customLabels && $this->application->destination->server->proxyType() !== 'NONE') {
|
if (! $this->customLabels && $this->application->destination->server->proxyType() !== 'NONE' && ! $this->application->settings->is_container_label_readonly_enabled) {
|
||||||
$this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n");
|
$this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n");
|
||||||
$this->application->custom_labels = base64_encode($this->customLabels);
|
$this->application->custom_labels = base64_encode($this->customLabels);
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
'destination_id' => ['type' => 'integer', 'description' => 'The unique identifier of the destination where the service is running.'],
|
'destination_id' => ['type' => 'integer', 'description' => 'The unique identifier of the destination where the service is running.'],
|
||||||
'connect_to_docker_network' => ['type' => 'boolean', 'description' => 'The flag to connect the service to the predefined Docker network.'],
|
'connect_to_docker_network' => ['type' => 'boolean', 'description' => 'The flag to connect the service to the predefined Docker network.'],
|
||||||
'is_container_label_escape_enabled' => ['type' => 'boolean', 'description' => 'The flag to enable the container label escape.'],
|
'is_container_label_escape_enabled' => ['type' => 'boolean', 'description' => 'The flag to enable the container label escape.'],
|
||||||
|
'is_container_label_readonly_enabled' => ['type' => 'boolean', 'description' => 'The flag to enable the container label readonly.'],
|
||||||
'config_hash' => ['type' => 'string', 'description' => 'The hash of the service configuration.'],
|
'config_hash' => ['type' => 'string', 'description' => 'The hash of the service configuration.'],
|
||||||
'service_type' => ['type' => 'string', 'description' => 'The type of the service.'],
|
'service_type' => ['type' => 'string', 'description' => 'The type of the service.'],
|
||||||
'created_at' => ['type' => 'string', 'description' => 'The date and time when the service was created.'],
|
'created_at' => ['type' => 'string', 'description' => 'The date and time when the service was created.'],
|
||||||
|
@ -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('application_settings', function (Blueprint $table) {
|
||||||
|
$table->boolean('is_container_label_readonly_enabled')->default(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('application_settings', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('is_container_label_readonly_enabled');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@ -239,6 +239,9 @@ class="underline" href="https://coolify.io/docs/knowledge-base/docker/registry"
|
|||||||
<x-forms.checkbox label="Escape special characters in labels?"
|
<x-forms.checkbox label="Escape special characters in labels?"
|
||||||
helper="By default, $ (and other chars) is escaped. So if you write $ in the labels, it will be saved as $$.<br><br>If you want to use env variables inside the labels, turn this off."
|
helper="By default, $ (and other chars) is escaped. So if you write $ in the labels, it will be saved as $$.<br><br>If you want to use env variables inside the labels, turn this off."
|
||||||
id="application.settings.is_container_label_escape_enabled" instantSave></x-forms.checkbox>
|
id="application.settings.is_container_label_escape_enabled" instantSave></x-forms.checkbox>
|
||||||
|
<x-forms.checkbox label="Readonly Labels"
|
||||||
|
helper="If you know what are you doing, you can enable this to edit the labels directly. Coolify won't update labels automatically. <br><br>Be careful, it could break the proxy configuration after you restart the container."
|
||||||
|
id="application.settings.is_container_label_readonly_enabled" instantSave></x-forms.checkbox>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@ -264,10 +267,13 @@ class="underline" href="https://coolify.io/docs/knowledge-base/docker/registry"
|
|||||||
|
|
||||||
<x-forms.textarea label="Container Labels" rows="15" id="customLabels"
|
<x-forms.textarea label="Container Labels" rows="15" id="customLabels"
|
||||||
monacoEditorLanguage="ini" useMonacoEditor></x-forms.textarea>
|
monacoEditorLanguage="ini" useMonacoEditor></x-forms.textarea>
|
||||||
<div class="w-72">
|
<div class="w-96">
|
||||||
<x-forms.checkbox label="Escape special characters in labels?"
|
<x-forms.checkbox label="Escape special characters in labels?"
|
||||||
helper="By default, $ (and other chars) is escaped. So if you write $ in the labels, it will be saved as $$.<br><br>If you want to use env variables inside the labels, turn this off."
|
helper="By default, $ (and other chars) is escaped. So if you write $ in the labels, it will be saved as $$.<br><br>If you want to use env variables inside the labels, turn this off."
|
||||||
id="application.settings.is_container_label_escape_enabled" instantSave></x-forms.checkbox>
|
id="application.settings.is_container_label_escape_enabled" instantSave></x-forms.checkbox>
|
||||||
|
<x-forms.checkbox label="Readonly Labels"
|
||||||
|
helper="If you know what are you doing, you can enable this to edit the labels directly. Coolify won't update labels automatically. <br><br>Be careful, it could break the proxy configuration after you restart the container."
|
||||||
|
id="application.settings.is_container_label_readonly_enabled" instantSave></x-forms.checkbox>
|
||||||
</div>
|
</div>
|
||||||
<x-modal-confirmation buttonFullWidth action="resetDefaultLabels"
|
<x-modal-confirmation buttonFullWidth action="resetDefaultLabels"
|
||||||
buttonTitle="Reset to Coolify Generated Labels">
|
buttonTitle="Reset to Coolify Generated Labels">
|
||||||
|
@ -3,11 +3,7 @@
|
|||||||
prevent
|
prevent
|
||||||
name collision. <br>To see the actual volume names, check the Deployable Compose file, or go to Storage
|
name collision. <br>To see the actual volume names, check the Deployable Compose file, or go to Storage
|
||||||
menu.</div>
|
menu.</div>
|
||||||
<div class="pb-2 w-72">
|
|
||||||
<x-forms.checkbox label="Escape special characters in labels?"
|
|
||||||
helper="By default, $ (and other chars) is escaped. So if you write $ in the labels, it will be saved as $$.<br><br>If you want to use env variables inside the labels, turn this off."
|
|
||||||
id="service.is_container_label_escape_enabled" instantSave></x-forms.checkbox>
|
|
||||||
</div>
|
|
||||||
<div x-cloak x-show="raw" class="font-mono">
|
<div x-cloak x-show="raw" class="font-mono">
|
||||||
<x-forms.textarea allowTab useMonacoEditor monacoEditorLanguage="yaml" rows="20"
|
<x-forms.textarea allowTab useMonacoEditor monacoEditorLanguage="yaml" rows="20"
|
||||||
id="service.docker_compose_raw">
|
id="service.docker_compose_raw">
|
||||||
@ -17,6 +13,11 @@
|
|||||||
<x-forms.textarea rows="20" readonly id="service.docker_compose">
|
<x-forms.textarea rows="20" readonly id="service.docker_compose">
|
||||||
</x-forms.textarea>
|
</x-forms.textarea>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="pt-2 w-72">
|
||||||
|
<x-forms.checkbox label="Escape special characters in labels?"
|
||||||
|
helper="By default, $ (and other chars) is escaped. So if you write $ in the labels, it will be saved as $$.<br><br>If you want to use env variables inside the labels, turn this off."
|
||||||
|
id="service.is_container_label_escape_enabled" instantSave></x-forms.checkbox>
|
||||||
|
</div>
|
||||||
<div class="flex justify-end w-full gap-2 pt-4">
|
<div class="flex justify-end w-full gap-2 pt-4">
|
||||||
<div class="flex items-end gap-2">
|
<div class="flex items-end gap-2">
|
||||||
<div x-cloak x-show="raw">
|
<div x-cloak x-show="raw">
|
||||||
|
Loading…
Reference in New Issue
Block a user