Merge pull request #7659 from appwrite/fix-runtime-list

Only return allowed runtimes in runtime list route
This commit is contained in:
Eldad A. Fux 2024-02-25 07:08:07 +01:00 committed by GitHub
commit 8e7ced68dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -420,17 +420,23 @@ App::get('/v1/functions/runtimes')
->label('sdk.response.model', Response::MODEL_RUNTIME_LIST) ->label('sdk.response.model', Response::MODEL_RUNTIME_LIST)
->inject('response') ->inject('response')
->action(function (Response $response) { ->action(function (Response $response) {
$runtimes = Config::getParam('runtimes'); $runtimes = Config::getParam('runtimes');
$runtimes = array_map(function ($key) use ($runtimes) { $allowList = \array_filter(\explode(',', App::getEnv('_APP_FUNCTIONS_RUNTIMES', '')));
$allowed = [];
foreach ($runtimes as $key => $runtime) {
if (!empty($allowList) && !\in_array($key, $allowList)) {
continue;
}
$runtimes[$key]['$id'] = $key; $runtimes[$key]['$id'] = $key;
return $runtimes[$key]; $allowed[] = $runtimes[$key];
}, array_keys($runtimes)); }
$response->dynamic(new Document([ $response->dynamic(new Document([
'total' => count($runtimes), 'total' => count($allowed),
'runtimes' => $runtimes 'runtimes' => $allowed
]), Response::MODEL_RUNTIME_LIST); ]), Response::MODEL_RUNTIME_LIST);
}); });