diff --git a/README.md b/README.md index c295b85..0d21e68 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ docker compose down | `command` | `string` | Commands to run after container is created. Maximum of 100 commands are allowed, each 1024 characters long. | | ' ' | | `timeout` | `integer` | Commands execution time in seconds | | 600 | | `remove` | `boolean` | Remove a runtime after execution | | false | -| `cpus` | `integer` | Maximum CPU cores runtime can utilize | | 1 | +| `cpus` | `float` | Maximum CPU cores runtime can utilize | | 1 | | `memory` | `integer` | Container RAM memory in MBs | | 512 | | `version` | `string` | Runtime Open Runtime version (allowed values: 'v2', 'v3') | | 'v3' | @@ -175,7 +175,7 @@ docker compose down | `source` | `string` | Path to source files | | ' ' | | `entrypoint` | `string` | Entrypoint of the code file | | ' ' | | `variables` | `json` | Environment variables passed into runtime | | [ ] | -| `cpus` | `integer` | Maximum CPU cores runtime can utilize | | 1 | +| `cpus` | `float` | Maximum CPU cores runtime can utilize | | 1 | | `memory` | `integer` | Container RAM memory in MBs | | 512 | | `version` | `string` | Runtime Open Runtime version (allowed values: 'v2', 'v3') | | 'v3' | | `runtimeEntrypoint` | `string` | Commands to run when creating a container. Maximum of 100 commands are allowed, each 1024 characters long. | | ' ' | diff --git a/app/http.php b/app/http.php index de0b5dd..c6341bc 100644 --- a/app/http.php +++ b/app/http.php @@ -35,6 +35,7 @@ use Utopia\Http\Route; use Utopia\Http\Validator\Assoc; use Utopia\Http\Validator\Boolean; +use Utopia\Http\Validator\FloatValidator; use Utopia\Http\Validator\Integer; use Utopia\Http\Validator\Text; use Utopia\Http\Validator\WhiteList; @@ -384,14 +385,14 @@ function removeAllRuntimes(Table $activeRuntimes, Orchestration $orchestration): ->param('command', '', new Text(1024), 'Commands to run after container is created. Maximum of 100 commands are allowed, each 1024 characters long.', true) ->param('timeout', 600, new Integer(), 'Commands execution time in seconds.', true) ->param('remove', false, new Boolean(), 'Remove a runtime after execution.', true) - ->param('cpus', 1, new Integer(), 'Container CPU.', true) + ->param('cpus', 1.0, new FloatValidator(), 'Container CPU.', true) ->param('memory', 512, new Integer(), 'Comtainer RAM memory.', true) ->param('version', 'v3', new WhiteList(['v2', 'v3']), 'Runtime Open Runtime version.', true) ->inject('orchestration') ->inject('activeRuntimes') ->inject('response') ->inject('log') - ->action(function (string $runtimeId, string $image, string $entrypoint, string $source, string $destination, array $variables, string $runtimeEntrypoint, string $command, int $timeout, bool $remove, int $cpus, int $memory, string $version, Orchestration $orchestration, Table $activeRuntimes, Response $response, Log $log) { + ->action(function (string $runtimeId, string $image, string $entrypoint, string $source, string $destination, array $variables, string $runtimeEntrypoint, string $command, int $timeout, bool $remove, float $cpus, int $memory, string $version, Orchestration $orchestration, Table $activeRuntimes, Response $response, Log $log) { $runtimeName = System::getHostname() . '-' . $runtimeId; $runtimeHostname = \uniqid(); @@ -711,7 +712,7 @@ function removeAllRuntimes(Table $activeRuntimes, Orchestration $orchestration): ->param('source', '', new Text(0), 'Path to source files.', true) ->param('entrypoint', '', new Text(256), 'Entrypoint of the code file.', true) ->param('variables', [], new Assoc(), 'Environment variables passed into runtime.', true) - ->param('cpus', 1, new Integer(), 'Container CPU.', true) + ->param('cpus', 1.0, new FloatValidator(), 'Container CPU.', true) ->param('memory', 512, new Integer(), 'Container RAM memory.', true) ->param('version', 'v3', new WhiteList(['v2', 'v3']), 'Runtime Open Runtime version.', true) ->param('runtimeEntrypoint', '', new Text(1024, 0), 'Commands to run when creating a container. Maximum of 100 commands are allowed, each 1024 characters long.', true) @@ -719,7 +720,7 @@ function removeAllRuntimes(Table $activeRuntimes, Orchestration $orchestration): ->inject('response') ->inject('log') ->action( - function (string $runtimeId, ?string $payload, string $path, string $method, array $headers, int $timeout, string $image, string $source, string $entrypoint, array $variables, int $cpus, int $memory, string $version, string $runtimeEntrypoint, Table $activeRuntimes, Response $response, Log $log) { + function (string $runtimeId, ?string $payload, string $path, string $method, array $headers, int $timeout, string $image, string $source, string $entrypoint, array $variables, float $cpus, int $memory, string $version, string $runtimeEntrypoint, Table $activeRuntimes, Response $response, Log $log) { if (empty($payload)) { $payload = ''; } diff --git a/composer.lock b/composer.lock index 3eba2d8..5eb0e8a 100644 --- a/composer.lock +++ b/composer.lock @@ -158,16 +158,16 @@ }, { "name": "utopia-php/framework", - "version": "0.34.2", + "version": "0.34.3", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "fd126c02b78cc80678c9638f7b335dfb4a841b78" + "reference": "e3bbca07c1df4e908ea9d3ce4f59367a7696b66b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/fd126c02b78cc80678c9638f7b335dfb4a841b78", - "reference": "fd126c02b78cc80678c9638f7b335dfb4a841b78", + "url": "https://api.github.com/repos/utopia-php/http/zipball/e3bbca07c1df4e908ea9d3ce4f59367a7696b66b", + "reference": "e3bbca07c1df4e908ea9d3ce4f59367a7696b66b", "shasum": "" }, "require": { @@ -184,7 +184,8 @@ "type": "library", "autoload": { "psr-4": { - "Utopia\\Http\\": "src/Http" + "Utopia\\": "src/", + "Tests\\E2E\\": "tests/e2e" } }, "notification-url": "https://packagist.org/downloads/", @@ -200,9 +201,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.34.2" + "source": "https://github.com/utopia-php/http/tree/0.34.3" }, - "time": "2024-02-20T11:36:56+00:00" + "time": "2024-07-02T15:08:46+00:00" }, { "name": "utopia-php/logger", @@ -260,16 +261,16 @@ }, { "name": "utopia-php/orchestration", - "version": "0.10.0", + "version": "0.10.1", "source": { "type": "git", "url": "https://github.com/utopia-php/orchestration.git", - "reference": "e417d32070f723eefa0768983e9bf00006f0a652" + "reference": "221d9aae8da1193b17dda6d000cb014ddd2802b7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/orchestration/zipball/e417d32070f723eefa0768983e9bf00006f0a652", - "reference": "e417d32070f723eefa0768983e9bf00006f0a652", + "url": "https://api.github.com/repos/utopia-php/orchestration/zipball/221d9aae8da1193b17dda6d000cb014ddd2802b7", + "reference": "221d9aae8da1193b17dda6d000cb014ddd2802b7", "shasum": "" }, "require": { @@ -304,9 +305,9 @@ ], "support": { "issues": "https://github.com/utopia-php/orchestration/issues", - "source": "https://github.com/utopia-php/orchestration/tree/0.10.0" + "source": "https://github.com/utopia-php/orchestration/tree/0.10.1" }, - "time": "2023-08-05T14:03:45+00:00" + "time": "2024-08-06T08:58:06+00:00" }, { "name": "utopia-php/preloader", @@ -664,16 +665,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.1", + "version": "1.12.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", "shasum": "" }, "require": { @@ -681,11 +682,12 @@ }, "conflict": { "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" + "doctrine/common": "<2.13.3 || >=3 <3.2.2" }, "require-dev": { "doctrine/collections": "^1.6.8", "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", @@ -711,7 +713,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" }, "funding": [ { @@ -719,20 +721,20 @@ "type": "tidelift" } ], - "time": "2023-03-08T13:26:56+00:00" + "time": "2024-06-12T14:39:25+00:00" }, { "name": "nikic/php-parser", - "version": "v5.0.2", + "version": "v5.1.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13" + "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/139676794dc1e9231bf7bcd123cfc0c99182cb13", - "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/683130c2ff8c2739f4822ff7ac5c873ec529abd1", + "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1", "shasum": "" }, "require": { @@ -743,7 +745,7 @@ }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^9.0" }, "bin": [ "bin/php-parse" @@ -775,9 +777,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.1.0" }, - "time": "2024-03-05T20:51:40+00:00" + "time": "2024-07-01T20:03:41+00:00" }, { "name": "phar-io/manifest", @@ -1277,45 +1279,45 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.19", + "version": "9.6.20", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8" + "reference": "49d7820565836236411f5dc002d16dd689cde42f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1a54a473501ef4cdeaae4e06891674114d79db8", - "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/49d7820565836236411f5dc002d16dd689cde42f", + "reference": "49d7820565836236411f5dc002d16dd689cde42f", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1 || ^2", + "doctrine/instantiator": "^1.5.0 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", + "myclabs/deep-copy": "^1.12.0", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.28", - "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-code-coverage": "^9.2.31", + "phpunit/php-file-iterator": "^3.0.6", "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", "sebastian/comparator": "^4.0.8", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.5", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.2", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.6", + "sebastian/global-state": "^5.0.7", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", "sebastian/version": "^3.0.2" }, "suggest": { @@ -1360,7 +1362,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.19" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.20" }, "funding": [ { @@ -1376,7 +1378,7 @@ "type": "tidelift" } ], - "time": "2024-04-05T04:35:58+00:00" + "time": "2024-07-10T11:45:39+00:00" }, { "name": "sebastian/cli-parser",