mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 23:24:46 +02:00
Add docker_labels
This commit is contained in:
parent
0c61a63191
commit
4c43fd1683
@ -329,10 +329,10 @@ class CreateServer extends CreateRecord
|
||||
})
|
||||
->selectablePlaceholder(false)
|
||||
->columnSpan([
|
||||
'default' => 2,
|
||||
'sm' => 2,
|
||||
'md' => 2,
|
||||
'lg' => 3,
|
||||
'default' => 1,
|
||||
'sm' => 1,
|
||||
'md' => 1,
|
||||
'lg' => 2,
|
||||
]),
|
||||
|
||||
Forms\Components\TextInput::make('image')
|
||||
@ -352,10 +352,21 @@ class CreateServer extends CreateRecord
|
||||
})
|
||||
->placeholder('Enter a custom Image')
|
||||
->columnSpan([
|
||||
'default' => 2,
|
||||
'sm' => 2,
|
||||
'md' => 2,
|
||||
'lg' => 3,
|
||||
'default' => 1,
|
||||
'sm' => 1,
|
||||
'md' => 1,
|
||||
'lg' => 2,
|
||||
]),
|
||||
|
||||
Forms\Components\TagsInput::make('docker_labels')
|
||||
->label('Docker Labels')
|
||||
->live()
|
||||
->placeholder('Enter custom Docker container labels')
|
||||
->columnSpan([
|
||||
'default' => 1,
|
||||
'sm' => 1,
|
||||
'md' => 1,
|
||||
'lg' => 2,
|
||||
]),
|
||||
|
||||
Forms\Components\Textarea::make('startup')
|
||||
|
@ -171,10 +171,10 @@ class EditServer extends EditRecord
|
||||
})
|
||||
->selectablePlaceholder(false)
|
||||
->columnSpan([
|
||||
'default' => 2,
|
||||
'sm' => 2,
|
||||
'md' => 2,
|
||||
'lg' => 3,
|
||||
'default' => 1,
|
||||
'sm' => 1,
|
||||
'md' => 1,
|
||||
'lg' => 2,
|
||||
]),
|
||||
|
||||
Forms\Components\TextInput::make('image')
|
||||
@ -194,10 +194,21 @@ class EditServer extends EditRecord
|
||||
})
|
||||
->placeholder('Enter a custom Image')
|
||||
->columnSpan([
|
||||
'default' => 2,
|
||||
'sm' => 2,
|
||||
'md' => 2,
|
||||
'lg' => 3,
|
||||
'default' => 1,
|
||||
'sm' => 1,
|
||||
'md' => 1,
|
||||
'lg' => 2,
|
||||
]),
|
||||
|
||||
Forms\Components\TagsInput::make('docker_labels')
|
||||
->label('Docker Labels')
|
||||
->live()
|
||||
->placeholder('Enter custom Docker container labels')
|
||||
->columnSpan([
|
||||
'default' => 1,
|
||||
'sm' => 1,
|
||||
'md' => 1,
|
||||
'lg' => 2,
|
||||
]),
|
||||
|
||||
Forms\Components\Textarea::make('startup')
|
||||
|
@ -184,6 +184,7 @@ class Server extends Model
|
||||
self::UPDATED_AT => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
'installed_at' => 'datetime',
|
||||
'docker_labels' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ class EggConfigurationService
|
||||
{
|
||||
// Get the legacy configuration structure for the server so that we
|
||||
// can property map the egg placeholders to values.
|
||||
$structure = $this->configurationStructureService->handle($server, [], true);
|
||||
$structure = $this->configurationStructureService->handle($server);
|
||||
|
||||
$response = [];
|
||||
// Normalize the output of the configuration for the new Daemon to more
|
||||
|
@ -20,7 +20,7 @@ class ServerConfigurationStructureService
|
||||
* DO NOT MODIFY THIS FUNCTION. This powers legacy code handling for the new daemon
|
||||
* daemon, if you modify the structure eggs will break unexpectedly.
|
||||
*/
|
||||
public function handle(Server $server, array $override = [], bool $legacy = false): array
|
||||
public function handle(Server $server, array $override = []): array
|
||||
{
|
||||
$clone = $server;
|
||||
// If any overrides have been set on this call make sure to update them on the
|
||||
@ -32,15 +32,13 @@ class ServerConfigurationStructureService
|
||||
}
|
||||
}
|
||||
|
||||
return $legacy
|
||||
? $this->returnLegacyFormat($clone)
|
||||
: $this->returnCurrentFormat($clone);
|
||||
return $this->returnFormat($clone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the new data format used for the daemon.
|
||||
* Returns the data format used for the daemon.
|
||||
*/
|
||||
protected function returnCurrentFormat(Server $server): array
|
||||
protected function returnFormat(Server $server): array
|
||||
{
|
||||
return [
|
||||
'uuid' => $server->uuid,
|
||||
@ -59,13 +57,12 @@ class ServerConfigurationStructureService
|
||||
'cpu_limit' => $server->cpu,
|
||||
'threads' => $server->threads,
|
||||
'disk_space' => $server->disk,
|
||||
// This field is deprecated — use "oom_killer".
|
||||
'oom_disabled' => !$server->oom_killer,
|
||||
'oom_killer' => $server->oom_killer,
|
||||
],
|
||||
'container' => [
|
||||
'image' => $server->image,
|
||||
'requires_rebuild' => false,
|
||||
'labels' => $server->docker_labels,
|
||||
],
|
||||
'allocations' => [
|
||||
'force_outgoing_ip' => $server->egg->force_outgoing_ip,
|
||||
@ -88,41 +85,4 @@ class ServerConfigurationStructureService
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the legacy server data format to continue support for old egg configurations
|
||||
* that have not yet been updated.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
protected function returnLegacyFormat(Server $server): array
|
||||
{
|
||||
return [
|
||||
'uuid' => $server->uuid,
|
||||
'build' => [
|
||||
'default' => [
|
||||
'ip' => $server->allocation->ip,
|
||||
'port' => $server->allocation->port,
|
||||
],
|
||||
'ports' => $server->allocations->groupBy('ip')->map(function ($item) {
|
||||
return $item->pluck('port');
|
||||
})->toArray(),
|
||||
'env' => $this->environment->handle($server),
|
||||
'oom_disabled' => !$server->oom_killer,
|
||||
'memory' => (int) $server->memory,
|
||||
'swap' => (int) $server->swap,
|
||||
'io' => (int) $server->io,
|
||||
'cpu' => (int) $server->cpu,
|
||||
'threads' => $server->threads,
|
||||
'disk' => (int) $server->disk,
|
||||
'image' => $server->image,
|
||||
],
|
||||
'service' => [
|
||||
'egg' => $server->egg->uuid,
|
||||
'skip_scripts' => $server->skip_scripts,
|
||||
],
|
||||
'rebuild' => false,
|
||||
'suspended' => $server->isSuspended() ? 1 : 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -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('servers', function (Blueprint $table) {
|
||||
$table->text('docker_labels')->default('[]');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->dropColumn('docker_labels');
|
||||
});
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user