Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly transform eggs that use inheritance (application api) #4970

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 16 additions & 8 deletions app/Transformers/Api/Application/EggTransformer.php
Expand Up @@ -41,11 +41,15 @@ public function getResourceName(): string
*/
public function transform(Egg $model): array
{
$files = json_decode($model->config_files, true, 512, JSON_THROW_ON_ERROR);
$model->loadMissing('configFrom');

$files = json_decode($model->inherit_config_files, true, 512, JSON_THROW_ON_ERROR);
if (empty($files)) {
$files = new \stdClass();
}

$model->loadMissing('scriptFrom');

return [
'id' => $model->id,
'uuid' => $model->uuid,
Expand All @@ -60,18 +64,18 @@ public function transform(Egg $model): array
'docker_images' => $model->docker_images,
'config' => [
'files' => $files,
'startup' => json_decode($model->config_startup, true),
'stop' => $model->config_stop,
'logs' => json_decode($model->config_logs, true),
'file_denylist' => $model->file_denylist,
'startup' => json_decode($model->inherit_config_startup, true),
'stop' => $model->inherit_config_stop,
'logs' => json_decode($model->inherit_config_logs, true),
'file_denylist' => $model->inherit_file_denylist,
'extends' => $model->config_from,
],
'startup' => $model->startup,
'script' => [
'privileged' => $model->script_is_privileged,
'install' => $model->script_install,
'entry' => $model->script_entry,
'container' => $model->script_container,
'install' => $model->copy_script_install,
'entry' => $model->copy_script_entry,
'container' => $model->copy_script_container,
'extends' => $model->copy_script_from,
],
$model->getCreatedAtColumn() => $this->formatTimestamp($model->created_at),
Expand Down Expand Up @@ -114,6 +118,8 @@ public function includeServers(Egg $model): Collection|NullResource
/**
* Include more detailed information about the configuration if this Egg is
* extending another.
*
* TODO: since the config info is already in the base response this include could be removed (in v2?)
*/
public function includeConfig(Egg $model): Item|NullResource
{
Expand All @@ -136,6 +142,8 @@ public function includeConfig(Egg $model): Item|NullResource
/**
* Include more detailed information about the script configuration if the
* Egg is extending another.
*
* TODO: since the script info is already in the base response this include could be removed (in v2?)
*/
public function includeScript(Egg $model): Item|NullResource
{
Expand Down