1
0
Fork 0
mirror of synced 2024-06-29 19:50:26 +12:00

Cleanup Collections

- Rename functionId to resourceId on Deployments
 - Add a resourceType to Deployments
 - Remove status, buildStdout and buildStderr from deployments
 - Rename dateCreated on Builds to startTime
 - Rename time on Builds to endTime
 - Added a deploymentId to Builds
 - Added duration to builds
 - Remove Vars from Build
This commit is contained in:
Bradley Schofield 2022-01-25 16:51:05 +00:00
parent 963a258fd6
commit 3c17afbaed
5 changed files with 109 additions and 127 deletions

View file

@ -1915,7 +1915,18 @@ $collections = [
'filters' => [], 'filters' => [],
], ],
[ [
'$id' => 'functionId', '$id' => 'resourceId',
'type' => Database::VAR_STRING,
'format' => '',
'size' => Database::LENGTH_KEY,
'signed' => true,
'required' => false,
'default' => null,
'array' => false,
'filters' => [],
],
[
'$id' => 'resourceType',
'type' => Database::VAR_STRING, 'type' => Database::VAR_STRING,
'format' => '', 'format' => '',
'size' => Database::LENGTH_KEY, 'size' => Database::LENGTH_KEY,
@ -1981,39 +1992,6 @@ $collections = [
'array' => false, 'array' => false,
'filters' => [], 'filters' => [],
], ],
[
'$id' => 'status',
'type' => Database::VAR_STRING,
'format' => '',
'size' => 128,
'signed' => true,
'required' => false,
'default' => '',
'array' => false,
'filters' => [],
],
[
'$id' => 'buildStdout',
'type' => Database::VAR_STRING,
'format' => '',
'size' => 4096,
'signed' => true,
'required' => false,
'default' => '',
'array' => false,
'filters' => [],
],
[
'$id' => 'buildStderr',
'type' => Database::VAR_STRING,
'format' => '',
'size' => 4096,
'signed' => true,
'required' => false,
'default' => '',
'array' => false,
'filters' => [],
],
[ [
'$id' => 'deploy', '$id' => 'deploy',
'type' => Database::VAR_BOOLEAN, 'type' => Database::VAR_BOOLEAN,
@ -2028,9 +2006,9 @@ $collections = [
], ],
'indexes' => [ 'indexes' => [
[ [
'$id' => '_key_function', '$id' => '_key_resource',
'type' => Database::INDEX_KEY, 'type' => Database::INDEX_KEY,
'attributes' => ['functionId'], 'attributes' => ['resourceId'],
'lengths' => [Database::LENGTH_KEY], 'lengths' => [Database::LENGTH_KEY],
'orders' => [Database::ORDER_ASC], 'orders' => [Database::ORDER_ASC],
], ],
@ -2050,7 +2028,7 @@ $collections = [
'name' => 'Builds', 'name' => 'Builds',
'attributes' => [ 'attributes' => [
[ [
'$id' => 'dateCreated', '$id' => 'startTime',
'type' => Database::VAR_INTEGER, 'type' => Database::VAR_INTEGER,
'format' => '', 'format' => '',
'size' => 0, 'size' => 0,
@ -2060,6 +2038,17 @@ $collections = [
'array' => false, 'array' => false,
'filters' => [], 'filters' => [],
], ],
[
'$id' => 'deploymentId',
'type' => Database::VAR_STRING,
'format' => '',
'size' => Database::LENGTH_KEY,
'signed' => true,
'required' => false,
'default' => null,
'array' => false,
'filters' => [],
],
[ [
'$id' => 'runtime', '$id' => 'runtime',
'type' => Database::VAR_STRING, 'type' => Database::VAR_STRING,
@ -2116,7 +2105,7 @@ $collections = [
'filters' => [], 'filters' => [],
], ],
[ [
'$id' => 'time', '$id' => 'endTime',
'type' => Database::VAR_INTEGER, 'type' => Database::VAR_INTEGER,
'format' => '', 'format' => '',
'size' => 0, 'size' => 0,
@ -2127,15 +2116,15 @@ $collections = [
'filters' => [], 'filters' => [],
], ],
[ [
'$id' => 'vars', '$id' => 'duration',
'type' => Database::VAR_STRING, 'type' => Database::VAR_INTEGER,
'format' => '', 'format' => '',
'size' => 16384, 'size' => 0,
'signed' => true, 'signed' => true,
'required' => false, 'required' => false,
'default' => new stdClass(), 'default' => null,
'array' => false, 'array' => false,
'filters' => ['json'], 'filters' => [],
], ],
[ [
'$id' => 'sourceType', '$id' => 'sourceType',

View file

@ -556,7 +556,8 @@ App::post('/v1/functions/:functionId/deployments')
// Remove deploy for all other deployments. // Remove deploy for all other deployments.
$deployments = $dbForProject->find('deployments', [ $deployments = $dbForProject->find('deployments', [
new Query('deploy', Query::TYPE_EQUAL, [true]), new Query('deploy', Query::TYPE_EQUAL, [true]),
new Query('functionId', Query::TYPE_EQUAL, [$functionId]) new Query('resourceId', Query::TYPE_EQUAL, [$functionId]),
new Query('resourceType', Query::TYPE_EQUAL, ['functions'])
]); ]);
foreach ($deployments as $deployment) { foreach ($deployments as $deployment) {
@ -570,15 +571,13 @@ App::post('/v1/functions/:functionId/deployments')
'$id' => $deploymentId, '$id' => $deploymentId,
'$read' => ['role:all'], '$read' => ['role:all'],
'$write' => ['role:all'], '$write' => ['role:all'],
'functionId' => $function->getId(), 'resourceId' => $function->getId(),
'resourceType' => 'functions',
'dateCreated' => time(), 'dateCreated' => time(),
'entrypoint' => $entrypoint, 'entrypoint' => $entrypoint,
'path' => $path, 'path' => $path,
'size' => $size, 'size' => $size,
'search' => implode(' ', [$deploymentId, $entrypoint]), 'search' => implode(' ', [$deploymentId, $entrypoint]),
'status' => 'processing',
'buildStdout' => '',
'buildStderr' => '',
'deploy' => ($deploy === 'true'), 'deploy' => ($deploy === 'true'),
])); ]));
@ -670,22 +669,12 @@ App::get('/v1/functions/:functionId/deployments')
$queries[] = new Query('search', Query::TYPE_SEARCH, [$search]); $queries[] = new Query('search', Query::TYPE_SEARCH, [$search]);
} }
$queries[] = new Query('functionId', Query::TYPE_EQUAL, [$function->getId()]); $queries[] = new Query('resourceId', Query::TYPE_EQUAL, [$function->getId()]);
$queries[] = new Query('resourceType', Query::TYPE_EQUAL, ['functions']);
$results = $dbForProject->find('deployments', $queries, $limit, $offset, [], [$orderType], $cursorDeployment ?? null, $cursorDirection); $results = $dbForProject->find('deployments', $queries, $limit, $offset, [], [$orderType], $cursorDeployment ?? null, $cursorDirection);
$sum = $dbForProject->count('deployments', $queries, APP_LIMIT_COUNT); $sum = $dbForProject->count('deployments', $queries, APP_LIMIT_COUNT);
// Get Current Build Data
foreach ($results as &$deployment) {
$build = $dbForProject->getDocument('builds', $deployment->getAttribute('buildId', ''));
$deployment['status'] = $build->getAttribute('status', 'processing');
$deployment['buildStdout'] = $build->getAttribute('stdout', '');
$deployment['buildStderr'] = $build->getAttribute('stderr', '');
}
var_dump($results);
$response->dynamic(new Document([ $response->dynamic(new Document([
'deployments' => $results, 'deployments' => $results,
'sum' => $sum, 'sum' => $sum,
@ -719,7 +708,7 @@ App::get('/v1/functions/:functionId/deployments/:deploymentId')
$deployment = $dbForProject->getDocument('deployments', $deploymentId); $deployment = $dbForProject->getDocument('deployments', $deploymentId);
if ($deployment->getAttribute('functionId') !== $function->getId()) { if ($deployment->getAttribute('resourceId') !== $function->getId()) {
throw new Exception('Deployment not found', 404); throw new Exception('Deployment not found', 404);
} }
@ -761,7 +750,7 @@ App::delete('/v1/functions/:functionId/deployments/:deploymentId')
$deployment = $dbForProject->getDocument('deployments', $deploymentId); $deployment = $dbForProject->getDocument('deployments', $deploymentId);
if ($deployment->getAttribute('functionId') !== $function->getId()) { if ($deployment->getAttribute('resourceId') !== $function->getId()) {
throw new Exception('Deployment not found', 404); throw new Exception('Deployment not found', 404);
} }
@ -857,7 +846,7 @@ App::post('/v1/functions/:functionId/executions')
$deployment = Authorization::skip(fn() => $dbForProject->getDocument('deployments', $function->getAttribute('deployment'))); $deployment = Authorization::skip(fn() => $dbForProject->getDocument('deployments', $function->getAttribute('deployment')));
if ($deployment->getAttribute('functionId') !== $function->getId()) { if ($deployment->getAttribute('resourceId') !== $function->getId()) {
throw new Exception('Deployment not found. Deploy deployment before trying to execute a function', 404); throw new Exception('Deployment not found. Deploy deployment before trying to execute a function', 404);
} }

View file

@ -176,7 +176,7 @@ function createRuntimeServer(string $functionId, string $projectId, string $depl
// Check if runtime is active // Check if runtime is active
$runtime = $runtimes[$function->getAttribute('runtime', '')] ?? null; $runtime = $runtimes[$function->getAttribute('runtime', '')] ?? null;
if ($deployment->getAttribute('functionId') !== $function->getId()) { if ($deployment->getAttribute('resourceId') !== $function->getId()) {
throw new Exception('deployment not found', 404); throw new Exception('deployment not found', 404);
} }
@ -186,6 +186,7 @@ function createRuntimeServer(string $functionId, string $projectId, string $depl
// Process environment variables // Process environment variables
$vars = \array_merge($function->getAttribute('vars', []), [ $vars = \array_merge($function->getAttribute('vars', []), [
'ENTRYPOINT_NAME' => $deployment->getAttribute('entrypoint', ''),
'APPWRITE_FUNCTION_ID' => $function->getId(), 'APPWRITE_FUNCTION_ID' => $function->getId(),
'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''), 'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''),
'APPWRITE_FUNCTION_DEPLOYMENT' => $deployment->getId(), 'APPWRITE_FUNCTION_DEPLOYMENT' => $deployment->getId(),
@ -195,8 +196,6 @@ function createRuntimeServer(string $functionId, string $projectId, string $depl
'INTERNAL_RUNTIME_KEY' => $secret 'INTERNAL_RUNTIME_KEY' => $secret
]); ]);
$vars = \array_merge($vars, $build->getAttribute('vars', [])); // for gettng endpoint.
$container = 'appwrite-function-' . $deployment->getId(); $container = 'appwrite-function-' . $deployment->getId();
if ($activeFunctions->exists($container) && !(\substr($activeFunctions->get($container)['status'], 0, 2) === 'Up')) { // Remove container if not online if ($activeFunctions->exists($container) && !(\substr($activeFunctions->get($container)['status'], 0, 2) === 'Up')) { // Remove container if not online
@ -328,7 +327,7 @@ function execute(string $trigger, string $projectId, string $executionId, string
$deployment = $database->getDocument('deployments', $function->getAttribute('deployment', '')); $deployment = $database->getDocument('deployments', $function->getAttribute('deployment', ''));
$build = $database->getDocument('builds', $deployment->getAttribute('buildId', '')); $build = $database->getDocument('builds', $deployment->getAttribute('buildId', ''));
if ($deployment->getAttribute('functionId') !== $function->getId()) { if ($deployment->getAttribute('resourceId') !== $function->getId()) {
throw new Exception('Deployment not found', 404); throw new Exception('Deployment not found', 404);
} }
@ -379,6 +378,7 @@ function execute(string $trigger, string $projectId, string $executionId, string
// Process environment variables // Process environment variables
$vars = \array_merge($function->getAttribute('vars', []), [ $vars = \array_merge($function->getAttribute('vars', []), [
'ENTRYPOINT_NAME' => $deployment->getAttribute('entrypoint', ''),
'APPWRITE_FUNCTION_ID' => $function->getId(), 'APPWRITE_FUNCTION_ID' => $function->getId(),
'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''), 'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''),
'APPWRITE_FUNCTION_DEPLOYMENT' => $deployment->getId(), 'APPWRITE_FUNCTION_DEPLOYMENT' => $deployment->getId(),
@ -393,8 +393,6 @@ function execute(string $trigger, string $projectId, string $executionId, string
'APPWRITE_FUNCTION_PROJECT_ID' => $projectId, 'APPWRITE_FUNCTION_PROJECT_ID' => $projectId,
]); ]);
$vars = \array_merge($vars, $build->getAttribute('vars', []));
$container = 'appwrite-function-' . $deployment->getId(); $container = 'appwrite-function-' . $deployment->getId();
try { try {
@ -405,7 +403,8 @@ function execute(string $trigger, string $projectId, string $executionId, string
'$id' => $buildId, '$id' => $buildId,
'$read' => ($userId !== '') ? ['user:' . $userId] : [], '$read' => ($userId !== '') ? ['user:' . $userId] : [],
'$write' => ['role:all'], '$write' => ['role:all'],
'dateCreated' => time(), 'startTime' => time(),
'deploymentId' => $deployment->getId(),
'status' => 'processing', 'status' => 'processing',
'outputPath' => '', 'outputPath' => '',
'runtime' => $function->getAttribute('runtime', ''), 'runtime' => $function->getAttribute('runtime', ''),
@ -413,15 +412,9 @@ function execute(string $trigger, string $projectId, string $executionId, string
'sourceType' => Storage::DEVICE_LOCAL, 'sourceType' => Storage::DEVICE_LOCAL,
'stdout' => '', 'stdout' => '',
'stderr' => '', 'stderr' => '',
'time' => 0, 'endTime' => 0,
'vars' => [ 'duration' => 0,
'ENTRYPOINT_NAME' => $deployment->getAttribute('entrypoint'), 'search' => implode(' ', [$deployment->getId(), $buildId]),
'APPWRITE_FUNCTION_ID' => $function->getId(),
'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''),
'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'],
'APPWRITE_FUNCTION_RUNTIME_VERSION' => $runtime['version'],
'APPWRITE_FUNCTION_PROJECT_ID' => $projectId,
]
])); ]));
$deployment->setAttribute('buildId', $buildId); $deployment->setAttribute('buildId', $buildId);
@ -475,6 +468,7 @@ function execute(string $trigger, string $projectId, string $executionId, string
// Process environment variables // Process environment variables
$vars = \array_merge($function->getAttribute('vars', []), [ $vars = \array_merge($function->getAttribute('vars', []), [
'ENTRYPOINT_NAME' => $deployment->getAttribute('entrypoint', ''),
'APPWRITE_FUNCTION_ID' => $function->getId(), 'APPWRITE_FUNCTION_ID' => $function->getId(),
'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''), 'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''),
'APPWRITE_FUNCTION_DEPLOYMENT' => $deployment->getId(), 'APPWRITE_FUNCTION_DEPLOYMENT' => $deployment->getId(),
@ -489,8 +483,6 @@ function execute(string $trigger, string $projectId, string $executionId, string
'APPWRITE_FUNCTION_PROJECT_ID' => $projectId 'APPWRITE_FUNCTION_PROJECT_ID' => $projectId
]); ]);
$vars = \array_merge($vars, $build->getAttribute('vars', []));
$stdout = ''; $stdout = '';
$stderr = ''; $stderr = '';
@ -511,7 +503,7 @@ function execute(string $trigger, string $projectId, string $executionId, string
$body = \json_encode([ $body = \json_encode([
'path' => '/usr/code', 'path' => '/usr/code',
'file' => $build->getAttribute('vars', [])['ENTRYPOINT_NAME'], 'file' => $vars['ENTRYPOINT_NAME'],
'env' => $vars, 'env' => $vars,
'payload' => $data, 'payload' => $data,
'timeout' => $function->getAttribute('timeout', (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900)) 'timeout' => $function->getAttribute('timeout', (int) App::getEnv('_APP_FUNCTIONS_TIMEOUT', 900))
@ -827,7 +819,8 @@ App::post('/v1/deployment')
'$id' => $buildId, '$id' => $buildId,
'$read' => (!empty($userId)) ? ['user:' . $userId] : [], '$read' => (!empty($userId)) ? ['user:' . $userId] : [],
'$write' => ['role:all'], '$write' => ['role:all'],
'dateCreated' => time(), 'startTime' => time(),
'deploymentId' => $deploymentId,
'status' => 'processing', 'status' => 'processing',
'runtime' => $function->getAttribute('runtime'), 'runtime' => $function->getAttribute('runtime'),
'outputPath' => '', 'outputPath' => '',
@ -835,15 +828,9 @@ App::post('/v1/deployment')
'sourceType' => Storage::DEVICE_LOCAL, 'sourceType' => Storage::DEVICE_LOCAL,
'stdout' => '', 'stdout' => '',
'stderr' => '', 'stderr' => '',
'time' => 0, 'endTime' => 0,
'vars' => [ 'duration' => 0,
'ENTRYPOINT_NAME' => $deployment->getAttribute('entrypoint'), 'search' => implode(' ', [$deployment->getId(), $buildId])
'APPWRITE_FUNCTION_ID' => $function->getId(),
'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''),
'APPWRITE_FUNCTION_RUNTIME_NAME' => $runtime['name'],
'APPWRITE_FUNCTION_RUNTIME_VERSION' => $runtime['version'],
'APPWRITE_FUNCTION_PROJECT_ID' => $projectID,
]
])); ]));
$deployment->setAttribute('buildId', $buildId); $deployment->setAttribute('buildId', $buildId);
@ -1037,11 +1024,28 @@ function runBuildStage(string $buildId, string $projectID): Document
throw new Exception('Code is not readable: ' . $build->getAttribute('source', '')); throw new Exception('Code is not readable: ' . $build->getAttribute('source', ''));
} }
$vars = $build->getAttribute('vars', []); $deployment = $database->getDocument('deployments', $build->getAttribute('deploymentId', ''));
$resourceId = $deployment->getAttribute('resourceId', '');
$resourceType = $deployment->getAttribute('resourceType', '');
if (empty($resourceId)) {
throw new Exception('Invalid resource ID on build ' . $build->getId());
}
if (empty($resourceType)) {
throw new Exception('Invalid resource type on build' . $build->getId());
}
$resource = $database->getDocument($resourceType, $resourceId);
if ($resource->isEmpty()) {
throw new Exception('Resource not found on build ' . $build->getId());
}
$vars = $resource->getAttribute('vars', []);
// Start tracking time // Start tracking time
$buildStart = \microtime(true); $buildStart = \time();
$time = \time();
$orchestration $orchestration
->setCpus(App::getEnv('_APP_FUNCTIONS_CPUS', 0)) ->setCpus(App::getEnv('_APP_FUNCTIONS_CPUS', 0))
@ -1067,7 +1071,7 @@ function runBuildStage(string $buildId, string $projectID): Document
workdir: '/usr/code', workdir: '/usr/code',
labels: [ labels: [
'appwrite-type' => 'function', 'appwrite-type' => 'function',
'appwrite-created' => strval($time), 'appwrite-created' => strval($buildStart),
'appwrite-runtime' => $build->getAttribute('runtime', ''), 'appwrite-runtime' => $build->getAttribute('runtime', ''),
'appwrite-project' => $projectID, 'appwrite-project' => $projectID,
'appwrite-build' => $build->getId(), 'appwrite-build' => $build->getId(),
@ -1181,19 +1185,24 @@ function runBuildStage(string $buildId, string $projectID): Document
->setAttribute('status', 'ready') ->setAttribute('status', 'ready')
->setAttribute('stdout', \utf8_encode(\mb_substr($buildStdout, -4096))) ->setAttribute('stdout', \utf8_encode(\mb_substr($buildStdout, -4096)))
->setAttribute('stderr', \utf8_encode(\mb_substr($buildStderr, -4096))) ->setAttribute('stderr', \utf8_encode(\mb_substr($buildStderr, -4096)))
->setAttribute('time', $time); ->setAttribute('startTime', $buildStart)
->setAttribute('endTime', \time())
->setAttribute('duration', \time() - $buildStart);
// Update build with built code attribute // Update build with built code attribute
$build = $database->updateDocument('builds', $buildId, $build); $build = $database->updateDocument('builds', $buildId, $build);
$buildEnd = \microtime(true); $buildEnd = \time();
Console::info('Build Stage Ran in ' . ($buildEnd - $buildStart) . ' seconds'); Console::info('Build Stage Ran in ' . ($buildEnd - $buildStart) . ' seconds');
} catch (Exception $e) { } catch (Exception $e) {
$build $build
->setAttribute('status', 'failed') ->setAttribute('status', 'failed')
->setAttribute('stdout', \utf8_encode(\mb_substr($buildStdout, -4096))) ->setAttribute('stdout', \utf8_encode(\mb_substr($buildStdout, -4096)))
->setAttribute('stderr', \utf8_encode(\mb_substr($e->getMessage(), -4096))); ->setAttribute('stderr', \utf8_encode(\mb_substr($e->getMessage(), -4096)))
->setAttribute('startTime', $buildStart)
->setAttribute('endTime', \microtime(true))
->setAttribute('duration', \microtime(true) - $buildStart);
$build = $database->updateDocument('builds', $buildId, $build); $build = $database->updateDocument('builds', $buildId, $build);

View file

@ -16,12 +16,18 @@ class Build extends Model
'default' => '', 'default' => '',
'example' => '5e5ea5c16897e', 'example' => '5e5ea5c16897e',
]) ])
->addRule('dateCreated', [ ->addRule('startTime', [
'type' => self::TYPE_INTEGER, 'type' => self::TYPE_INTEGER,
'description' => 'The deployment creation date in Unix timestamp.', 'description' => 'The deployment creation date in Unix timestamp.',
'default' => 0, 'default' => 0,
'example' => 1592981250, 'example' => 1592981250,
]) ])
->addRule('deploymentId', [
'type' => self::TYPE_STRING,
'description' => 'The deployment that created this build',
'default' => '',
'example' => '5e5ea5c16897e',
])
// Build Status // Build Status
// Failed - The deployment build has failed. More details can usually be found in buildStderr // Failed - The deployment build has failed. More details can usually be found in buildStderr
// Ready - The deployment build was successful and the deployment is ready to be deployed // Ready - The deployment build was successful and the deployment is ready to be deployed
@ -45,7 +51,13 @@ class Build extends Model
'default' => '', 'default' => '',
'example' => '', 'example' => '',
]) ])
->addRule('time', [ ->addRule('endTime', [
'type' => self::TYPE_INTEGER,
'description' => 'The time the build was finished in Unix timestamp.',
'default' => 0,
'example' => 0,
])
->addRule('duration', [
'type' => self::TYPE_INTEGER, 'type' => self::TYPE_INTEGER,
'description' => 'The build time in seconds.', 'description' => 'The build time in seconds.',
'default' => 0, 'default' => 0,

View file

@ -16,12 +16,18 @@ class Deployment extends Model
'default' => '', 'default' => '',
'example' => '5e5ea5c16897e', 'example' => '5e5ea5c16897e',
]) ])
->addRule('functionId', [ ->addRule('resourceId', [
'type' => self::TYPE_STRING, 'type' => self::TYPE_STRING,
'description' => 'Function ID.', 'description' => 'Resource ID.',
'default' => '', 'default' => '',
'example' => '5e5ea6g16897e', 'example' => '5e5ea6g16897e',
]) ])
->addRule('resourceType', [
'type' => self::TYPE_STRING,
'description' => 'Resource type.',
'default' => '',
'example' => 'functions',
])
->addRule('dateCreated', [ ->addRule('dateCreated', [
'type' => self::TYPE_INTEGER, 'type' => self::TYPE_INTEGER,
'description' => 'The deployment creation date in Unix timestamp.', 'description' => 'The deployment creation date in Unix timestamp.',
@ -30,7 +36,7 @@ class Deployment extends Model
]) ])
->addRule('entrypoint', [ ->addRule('entrypoint', [
'type' => self::TYPE_STRING, 'type' => self::TYPE_STRING,
'description' => 'The entrypoint file to use to execute the delpoyment code.', 'description' => 'The entrypoint file to use to execute the deployment code.',
'default' => '', 'default' => '',
'example' => 'enabled', 'example' => 'enabled',
]) ])
@ -40,35 +46,12 @@ class Deployment extends Model
'default' => 0, 'default' => 0,
'example' => 128, 'example' => 128,
]) ])
// Build Status
// Failed - The deployment build has failed. More details can usually be found in buildStderr
// Ready - The deployment build was successful and the deployment is ready to be deployed
// Processing - The deployment is currently waiting to have a build triggered
// Building - The deployment is currently being built
->addRule('status', [
'type' => self::TYPE_STRING,
'description' => 'The deployment\'s current built status',
'default' => '',
'example' => 'ready',
])
->addRule('buildId', [ ->addRule('buildId', [
'type' => self::TYPE_STRING, 'type' => self::TYPE_STRING,
'description' => 'The current build ID.', 'description' => 'The current build ID.',
'default' => '', 'default' => '',
'example' => '5e5ea5c16897e', 'example' => '5e5ea5c16897e',
]) ])
->addRule('buildStdout', [
'type' => self::TYPE_STRING,
'description' => 'The stdout of the build.',
'default' => '',
'example' => '',
])
->addRule('buildStderr', [
'type' => self::TYPE_STRING,
'description' => 'The stderr of the build.',
'default' => '',
'example' => '',
])
->addRule('deploy', [ ->addRule('deploy', [
'type' => self::TYPE_BOOLEAN, 'type' => self::TYPE_BOOLEAN,
'description' => 'Whether the deployment should be automatically deployed.', 'description' => 'Whether the deployment should be automatically deployed.',