Skip to content

Commit 638ea2e

Browse files
committed
Support creating/updating docker images on eggs
1 parent 78c4ac8 commit 638ea2e

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

app/Http/Controllers/Admin/Nests/EggController.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,14 @@ public function create(): View
7878
*/
7979
public function store(EggFormRequest $request): RedirectResponse
8080
{
81-
$egg = $this->creationService->handle($request->normalize());
81+
$data = $request->normalize();
82+
if (!empty($data['docker_images']) && !is_array($data['docker_images'])) {
83+
$data['docker_images'] = array_map(function ($value) {
84+
return trim($value);
85+
}, explode("\n", $data['docker_images']));
86+
}
87+
88+
$egg = $this->creationService->handle($data);
8289
$this->alert->success(trans('admin/nests.eggs.notices.egg_created'))->flash();
8390

8491
return redirect()->route('admin.nests.egg.view', $egg->id);
@@ -108,7 +115,14 @@ public function view(Egg $egg): View
108115
*/
109116
public function update(EggFormRequest $request, Egg $egg): RedirectResponse
110117
{
111-
$this->updateService->handle($egg, $request->normalize());
118+
$data = $request->normalize();
119+
if (!empty($data['docker_images']) && !is_array($data['docker_images'])) {
120+
$data['docker_images'] = array_map(function ($value) {
121+
return trim($value);
122+
}, explode("\n", $data['docker_images']));
123+
}
124+
125+
$this->updateService->handle($egg, $data);
112126
$this->alert->success(trans('admin/nests.eggs.notices.updated'))->flash();
113127

114128
return redirect()->route('admin.nests.egg.view', $egg->id);

app/Http/Requests/Admin/Egg/EggFormRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function rules()
2121
$rules = [
2222
'name' => 'required|string|max:191',
2323
'description' => 'nullable|string',
24-
'docker_image' => 'required|string|max:191',
24+
'docker_images' => 'required|string',
2525
'startup' => 'required|string',
2626
'config_from' => 'sometimes|bail|nullable|numeric',
2727
'config_stop' => 'required_without:config_from|nullable|string|max:191',

resources/views/admin/eggs/new.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@
5353
</div>
5454
<div class="col-sm-6">
5555
<div class="form-group">
56-
<label for="pDockerImage" class="control-label">Docker Image</label>
57-
<input type="text" id="pDockerImage" name="docker_image" value="{{ old('docker_image') }}" placeholder="quay.io/pterodactyl/service" class="form-control" />
58-
<p class="text-muted small">The default docker image that should be used for new servers using this Egg. This can be changed per-server.</p>
56+
<label for="pDockerImage" class="control-label">Docker Images</label>
57+
<textarea id="pDockerImages" name="docker_images" rows="4" placeholder="quay.io/pterodactyl/service" class="form-control">{{ old('docker_images') }}</textarea>
58+
<p class="text-muted small">The docker images available to servers using this egg. Enter one per line. Users will be able to select from this list of images if more than one value is provided.</p>
5959
</div>
6060
<div class="form-group">
6161
<label for="pStartup" class="control-label">Startup Command</label>
62-
<textarea id="pStartup" name="startup" class="form-control" rows="14">{{ old('startup') }}</textarea>
62+
<textarea id="pStartup" name="startup" class="form-control" rows="10">{{ old('startup') }}</textarea>
6363
<p class="text-muted small">The default startup command that should be used for new servers created with this Egg. You can change this per-server as needed.</p>
6464
</div>
6565
</div>

resources/views/admin/eggs/view.blade.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,20 @@
8282
<p class="text-muted small">The author of this version of the Egg. Uploading a new Egg configuration from a different author will change this.</p>
8383
</div>
8484
<div class="form-group">
85-
<label for="pDockerImage" class="control-label">Docker Image <span class="field-required"></span></label>
86-
<input type="text" id="pDockerImage" name="docker_image" value="{{ $egg->docker_image }}" class="form-control" />
87-
<p class="text-muted small">The default docker image that should be used for new servers using this Egg. This can be changed per-server as needed.</p>
85+
<label for="pDockerImage" class="control-label">Docker Images <span class="field-required"></span></label>
86+
<textarea id="pDockerImages" name="docker_images" class="form-control" rows="4">{{ implode("\n", $egg->docker_images) }}</textarea>
87+
<p class="text-muted small">The docker images available to servers using this egg. Enter one per line. Users will be able to select from this list of images if more than one value is provided.</p>
8888
</div>
8989
</div>
9090
<div class="col-sm-6">
9191
<div class="form-group">
9292
<label for="pDescription" class="control-label">Description</label>
93-
<textarea id="pDescription" name="description" class="form-control" rows="6">{{ $egg->description }}</textarea>
93+
<textarea id="pDescription" name="description" class="form-control" rows="8">{{ $egg->description }}</textarea>
9494
<p class="text-muted small">A description of this Egg that will be displayed throughout the Panel as needed.</p>
9595
</div>
9696
<div class="form-group">
9797
<label for="pStartup" class="control-label">Startup Command <span class="field-required"></span></label>
98-
<textarea id="pStartup" name="startup" class="form-control" rows="6">{{ $egg->startup }}</textarea>
98+
<textarea id="pStartup" name="startup" class="form-control" rows="8">{{ $egg->startup }}</textarea>
9999
<p class="text-muted small">The default startup command that should be used for new servers using this Egg.</p>
100100
</div>
101101
</div>

0 commit comments

Comments
 (0)