An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Add comment field support to environment variable API endpoints
Andras Bacsai87f9ce0674c0
diff --git a/app/Http/Controllers/Api/ApplicationsController.php b/app/Http/Controllers/Api/ApplicationsController.phpindex 92c5f04a25..def672a759 100644--- a/app/Http/Controllers/Api/ApplicationsController.php+++ b/app/Http/Controllers/Api/ApplicationsController.php@@ -2529,7 +2529,7 @@ class ApplicationsController extends Controller)]public function update_env_by_uuid(Request $request){- $allowedFields = ['key', 'value', 'is_preview', 'is_literal', 'is_multiline', 'is_shown_once', 'is_runtime', 'is_buildtime'];+ $allowedFields = ['key', 'value', 'is_preview', 'is_literal', 'is_multiline', 'is_shown_once', 'is_runtime', 'is_buildtime', 'comment'];$teamId = getTeamIdFromToken();if (is_null($teamId)) {@@ -2559,6 +2559,7 @@ class ApplicationsController extends Controller'is_shown_once' => 'boolean','is_runtime' => 'boolean','is_buildtime' => 'boolean',+ 'comment' => 'string|nullable|max:256',]);$extraFields = array_diff(array_keys($request->all()), $allowedFields);@@ -2600,6 +2601,9 @@ class ApplicationsController extends Controllerif ($request->has('is_buildtime') && $env->is_buildtime != $request->is_buildtime) {$env->is_buildtime = $request->is_buildtime;}+ if ($request->has('comment') && $env->comment != $request->comment) {+ $env->comment = $request->comment;+ }$env->save();return response()->json($this->removeSensitiveData($env))->setStatusCode(201);@@ -2630,6 +2634,9 @@ class ApplicationsController extends Controllerif ($request->has('is_buildtime') && $env->is_buildtime != $request->is_buildtime) {$env->is_buildtime = $request->is_buildtime;}+ if ($request->has('comment') && $env->comment != $request->comment) {+ $env->comment = $request->comment;+ }$env->save();return response()->json($this->removeSensitiveData($env))->setStatusCode(201);@@ -2926,7 +2933,7 @@ class ApplicationsController extends Controller)]public function create_env(Request $request){- $allowedFields = ['key', 'value', 'is_preview', 'is_literal', 'is_multiline', 'is_shown_once', 'is_runtime', 'is_buildtime'];+ $allowedFields = ['key', 'value', 'is_preview', 'is_literal', 'is_multiline', 'is_shown_once', 'is_runtime', 'is_buildtime', 'comment'];$teamId = getTeamIdFromToken();if (is_null($teamId)) {@@ -2951,6 +2958,7 @@ class ApplicationsController extends Controller'is_shown_once' => 'boolean','is_runtime' => 'boolean','is_buildtime' => 'boolean',+ 'comment' => 'string|nullable|max:256',]);$extraFields = array_diff(array_keys($request->all()), $allowedFields);@@ -2986,6 +2994,7 @@ class ApplicationsController extends Controller'is_shown_once' => $request->is_shown_once ?? false,'is_runtime' => $request->is_runtime ?? true,'is_buildtime' => $request->is_buildtime ?? true,+ 'comment' => $request->comment ?? null,'resourceable_type' => get_class($application),'resourceable_id' => $application->id,]);@@ -3010,6 +3019,7 @@ class ApplicationsController extends Controller'is_shown_once' => $request->is_shown_once ?? false,'is_runtime' => $request->is_runtime ?? true,'is_buildtime' => $request->is_buildtime ?? true,+ 'comment' => $request->comment ?? null,'resourceable_type' => get_class($application),'resourceable_id' => $application->id,]);diff --git a/app/Http/Controllers/Api/ServicesController.php b/app/Http/Controllers/Api/ServicesController.phpindex 587f49fa5a..802cfa1a39 100644--- a/app/Http/Controllers/Api/ServicesController.php+++ b/app/Http/Controllers/Api/ServicesController.php@@ -1031,6 +1031,7 @@ class ServicesController extends Controller'is_literal' => 'boolean','is_multiline' => 'boolean','is_shown_once' => 'boolean',+ 'comment' => 'string|nullable|max:256',]);if ($validator->fails()) {@@ -1046,7 +1047,19 @@ class ServicesController extends Controllerreturn response()->json(['message' => 'Environment variable not found.'], 404);}- $env->fill($request->all());+ $env->value = $request->value;+ if ($request->has('is_literal')) {+ $env->is_literal = $request->is_literal;+ }+ if ($request->has('is_multiline')) {+ $env->is_multiline = $request->is_multiline;+ }+ if ($request->has('is_shown_once')) {+ $env->is_shown_once = $request->is_shown_once;+ }+ if ($request->has('comment')) {+ $env->comment = $request->comment;+ }$env->save();return response()->json($this->removeSensitiveData($env))->setStatusCode(201);@@ -1276,6 +1289,7 @@ class ServicesController extends Controller'is_literal' => 'boolean','is_multiline' => 'boolean','is_shown_once' => 'boolean',+ 'comment' => 'string|nullable|max:256',]);if ($validator->fails()) {@@ -1293,7 +1307,14 @@ class ServicesController extends Controller], 409);}- $env = $service->environment_variables()->create($request->all());+ $env = $service->environment_variables()->create([+ 'key' => $key,+ 'value' => $request->value,+ 'is_literal' => $request->is_literal ?? false,+ 'is_multiline' => $request->is_multiline ?? false,+ 'is_shown_once' => $request->is_shown_once ?? false,+ 'comment' => $request->comment ?? null,+ ]);return response()->json($this->removeSensitiveData($env))->setStatusCode(201);}