From c92a820c6db2ca162e6e1ade2a6e725f1cccda08 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Mon, 21 Jun 2021 15:42:39 +0100 Subject: [PATCH] Renamed `env` param on `/v1/functions` to `runtime` --- CHANGES.md | 3 +++ app/controllers/api/functions.php | 6 +++--- .../e2e/Services/Functions/FunctionsCustomClientTest.php | 4 ++-- .../e2e/Services/Functions/FunctionsCustomServerTest.php | 8 ++++---- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0dd92eeff6..ecea3a3ac1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,9 @@ - Add Anonymous Account Placeholder - Upgraded telegraf docker image version to v1.1.0 +## Breaking Changes (Read before upgrading!) +- Renamed `env` param on `/v1/functions` to `runtime` + ## Bugs - Fixed bug when removing a project member on the Appwrite console (#1214) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 0f009aa404..8d49f38028 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -39,14 +39,14 @@ App::post('/v1/functions') ->label('sdk.response.model', Response::MODEL_FUNCTION) ->param('name', '', new Text(128), 'Function name. Max length: 128 chars.') ->param('execute', [], new ArrayList(new Text(64)), 'An array of strings with execution permissions. By default no user is granted with any execute permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') - ->param('env', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Execution enviornment.') + ->param('runtime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Execution enviornment.') ->param('vars', [], new Assoc(), 'Key-value JSON object.', true) ->param('events', [], new ArrayList(new WhiteList(array_keys(Config::getParam('events')), true)), 'Events list.', true) ->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true) ->param('timeout', 15, new Range(1, 900), 'Function maximum execution time in seconds.', true) ->inject('response') ->inject('projectDB') - ->action(function ($name, $execute, $env, $vars, $events, $schedule, $timeout, $response, $projectDB) { + ->action(function ($name, $execute, $runtime, $vars, $events, $schedule, $timeout, $response, $projectDB) { /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ @@ -59,7 +59,7 @@ App::post('/v1/functions') 'dateUpdated' => time(), 'status' => 'disabled', 'name' => $name, - 'env' => $env, + 'runtime' => $runtime, 'tag' => '', 'vars' => $vars, 'events' => $events, diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index 12a9edf245..8ba16f8145 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -54,7 +54,7 @@ class FunctionsCustomClientTest extends Scope ], [ 'name' => 'Test', 'execute' => ['user:'.$this->getUser()['$id']], - 'env' => 'php-8.0', + 'runtime' => 'php-8.0', 'vars' => [ 'funcKey1' => 'funcValue1', 'funcKey2' => 'funcValue2', @@ -140,7 +140,7 @@ class FunctionsCustomClientTest extends Scope ], [ 'name' => 'Test', 'execute' => ['*'], - 'env' => 'php-8.0', + 'runtime' => 'php-8.0', 'vars' => [ 'funcKey1' => 'funcValue1', 'funcKey2' => 'funcValue2', diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index edd9081c91..b3140a7690 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -24,7 +24,7 @@ class FunctionsCustomServerTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'name' => 'Test', - 'env' => 'php-8.0', + 'runtime' => 'php-8.0', 'vars' => [ 'funcKey1' => 'funcValue1', 'funcKey2' => 'funcValue2', @@ -327,7 +327,7 @@ class FunctionsCustomServerTest extends Scope $this->assertStringContainsString('PHP', $execution['body']['stdout']); $this->assertStringContainsString('8.0', $execution['body']['stdout']); $this->assertEquals('', $execution['body']['stderr']); - $this->assertGreaterThan(0.100, $execution['body']['time']); + $this->assertGreaterThan(0.05, $execution['body']['time']); $this->assertLessThan(0.500, $execution['body']['time']); /** @@ -462,7 +462,7 @@ class FunctionsCustomServerTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'name' => 'Test '.$name, - 'env' => $name, + 'runtime' => $name, 'vars' => [], 'events' => [], 'schedule' => '', @@ -540,7 +540,7 @@ class FunctionsCustomServerTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'name' => 'Test '.$name, - 'env' => $name, + 'runtime' => $name, 'vars' => [], 'events' => [], 'schedule' => '',