Support creating/updating docker images on eggs

This commit is contained in:
Dane Everitt 2020-12-13 10:13:32 -08:00
parent 78c4ac80bc
commit 638ea2e815
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
4 changed files with 26 additions and 12 deletions

View file

@ -78,7 +78,14 @@ class EggController extends Controller
*/
public function store(EggFormRequest $request): RedirectResponse
{
$egg = $this->creationService->handle($request->normalize());
$data = $request->normalize();
if (!empty($data['docker_images']) && !is_array($data['docker_images'])) {
$data['docker_images'] = array_map(function ($value) {
return trim($value);
}, explode("\n", $data['docker_images']));
}
$egg = $this->creationService->handle($data);
$this->alert->success(trans('admin/nests.eggs.notices.egg_created'))->flash();
return redirect()->route('admin.nests.egg.view', $egg->id);
@ -108,7 +115,14 @@ class EggController extends Controller
*/
public function update(EggFormRequest $request, Egg $egg): RedirectResponse
{
$this->updateService->handle($egg, $request->normalize());
$data = $request->normalize();
if (!empty($data['docker_images']) && !is_array($data['docker_images'])) {
$data['docker_images'] = array_map(function ($value) {
return trim($value);
}, explode("\n", $data['docker_images']));
}
$this->updateService->handle($egg, $data);
$this->alert->success(trans('admin/nests.eggs.notices.updated'))->flash();
return redirect()->route('admin.nests.egg.view', $egg->id);

View file

@ -21,7 +21,7 @@ class EggFormRequest extends AdminFormRequest
$rules = [
'name' => 'required|string|max:191',
'description' => 'nullable|string',
'docker_image' => 'required|string|max:191',
'docker_images' => 'required|string',
'startup' => 'required|string',
'config_from' => 'sometimes|bail|nullable|numeric',
'config_stop' => 'required_without:config_from|nullable|string|max:191',

View file

@ -53,13 +53,13 @@
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="pDockerImage" class="control-label">Docker Image</label>
<input type="text" id="pDockerImage" name="docker_image" value="{{ old('docker_image') }}" placeholder="quay.io/pterodactyl/service" class="form-control" />
<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>
<label for="pDockerImage" class="control-label">Docker Images</label>
<textarea id="pDockerImages" name="docker_images" rows="4" placeholder="quay.io/pterodactyl/service" class="form-control">{{ old('docker_images') }}</textarea>
<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>
</div>
<div class="form-group">
<label for="pStartup" class="control-label">Startup Command</label>
<textarea id="pStartup" name="startup" class="form-control" rows="14">{{ old('startup') }}</textarea>
<textarea id="pStartup" name="startup" class="form-control" rows="10">{{ old('startup') }}</textarea>
<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>
</div>
</div>

View file

@ -82,20 +82,20 @@
<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>
</div>
<div class="form-group">
<label for="pDockerImage" class="control-label">Docker Image <span class="field-required"></span></label>
<input type="text" id="pDockerImage" name="docker_image" value="{{ $egg->docker_image }}" class="form-control" />
<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>
<label for="pDockerImage" class="control-label">Docker Images <span class="field-required"></span></label>
<textarea id="pDockerImages" name="docker_images" class="form-control" rows="4">{{ implode("\n", $egg->docker_images) }}</textarea>
<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>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="pDescription" class="control-label">Description</label>
<textarea id="pDescription" name="description" class="form-control" rows="6">{{ $egg->description }}</textarea>
<textarea id="pDescription" name="description" class="form-control" rows="8">{{ $egg->description }}</textarea>
<p class="text-muted small">A description of this Egg that will be displayed throughout the Panel as needed.</p>
</div>
<div class="form-group">
<label for="pStartup" class="control-label">Startup Command <span class="field-required"></span></label>
<textarea id="pStartup" name="startup" class="form-control" rows="6">{{ $egg->startup }}</textarea>
<textarea id="pStartup" name="startup" class="form-control" rows="8">{{ $egg->startup }}</textarea>
<p class="text-muted small">The default startup command that should be used for new servers using this Egg.</p>
</div>
</div>