Add service pack reference to server and send to daemon
This commit is contained in:
parent
238f08f222
commit
c4a4b84bd3
4 changed files with 61 additions and 8 deletions
|
@ -86,6 +86,7 @@ class ServerRepository
|
|||
'disk' => 'required|numeric|min:0',
|
||||
'service' => 'bail|required|numeric|min:1|exists:services,id',
|
||||
'option' => 'bail|required|numeric|min:1|exists:service_options,id',
|
||||
'pack' => 'bail|required|numeric|min:0'
|
||||
'startup' => 'string',
|
||||
'custom_image_name' => 'required_if:use_custom_image,on',
|
||||
'auto_deploy' => 'sometimes|boolean'
|
||||
|
@ -161,6 +162,18 @@ class ServerRepository
|
|||
throw new DisplayException('The requested service option does not exist for the specified service.');
|
||||
}
|
||||
|
||||
// Validate the Pack
|
||||
if ($data['pack'] === 0) {
|
||||
$data['pack'] = null;
|
||||
}
|
||||
|
||||
if (!is_null($data['pack'])) {
|
||||
$pack = Models\ServicePack::where('id', $data['pack'])->where('option', $data['option'])->first();
|
||||
if (!$pack) {
|
||||
throw new DisplayException('The requested service pack does not seem to exist for this combination.');
|
||||
}
|
||||
}
|
||||
|
||||
// Load up the Service Information
|
||||
$service = Models\Service::find($option->parent_service);
|
||||
|
||||
|
@ -248,6 +261,7 @@ class ServerRepository
|
|||
'allocation' => $allocation->id,
|
||||
'service' => $data['service'],
|
||||
'option' => $data['option'],
|
||||
'pack' => $data['pack'],
|
||||
'startup' => $data['startup'],
|
||||
'daemonSecret' => $uuid->generate('servers', 'daemonSecret'),
|
||||
'image' => (isset($data['custom_image_name'])) ? $data['custom_image_name'] : $option->docker_image,
|
||||
|
@ -297,10 +311,10 @@ class ServerRepository
|
|||
'build' => [
|
||||
'default' => [
|
||||
'ip' => $allocation->ip,
|
||||
'port' => (int) $allocation->port
|
||||
'port' => (int) $allocation->port,
|
||||
],
|
||||
'ports' => [
|
||||
(string) $allocation->ip => [ (int) $allocation->port ]
|
||||
(string) $allocation->ip => [ (int) $allocation->port ],
|
||||
],
|
||||
'env' => $environmentVariables,
|
||||
'memory' => (int) $server->memory,
|
||||
|
@ -308,16 +322,17 @@ class ServerRepository
|
|||
'io' => (int) $server->io,
|
||||
'cpu' => (int) $server->cpu,
|
||||
'disk' => (int) $server->disk,
|
||||
'image' => (isset($data['custom_image_name'])) ? $data['custom_image_name'] : $option->docker_image
|
||||
'image' => (isset($data['custom_image_name'])) ? $data['custom_image_name'] : $option->docker_image,
|
||||
],
|
||||
'service' => [
|
||||
'type' => $service->file,
|
||||
'option' => $option->tag
|
||||
'option' => $option->tag,
|
||||
'pack' => (isset($pack)) ? $pack->uuid : null,
|
||||
],
|
||||
'keys' => [
|
||||
(string) $server->daemonSecret => $this->daemonPermissions
|
||||
(string) $server->daemonSecret => $this->daemonPermissions,
|
||||
],
|
||||
'rebuild' => false
|
||||
'rebuild' => false,
|
||||
]
|
||||
]);
|
||||
|
||||
|
|
Reference in a new issue