From d7a40e2b4d893af70ee936cb1910a97dbe8d291c Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Sun, 2 Jun 2024 23:14:41 +0530 Subject: [PATCH] Remove the code to fetch build document --- app/controllers/api/functions.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 7ad6e95cd1..f2da30b39a 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1436,7 +1436,7 @@ App::delete('/v1/functions/:functionId/deployments/:deploymentId') App::post('/v1/functions/:functionId/deployments/:deploymentId/build') ->alias('/v1/functions/:functionId/deployments/:deploymentId/builds/:buildId') ->groups(['api', 'functions']) - ->desc('Create build') + ->desc('Rebuild deployment') ->label('scope', 'functions.write') ->label('event', 'functions.[functionId].deployments.[deploymentId].update') ->label('audits.event', 'deployment.update') @@ -1449,7 +1449,7 @@ App::post('/v1/functions/:functionId/deployments/:deploymentId/build') ->label('sdk.response.model', Response::MODEL_NONE) ->param('functionId', '', new UID(), 'Function ID.') ->param('deploymentId', '', new UID(), 'Deployment ID.') - ->param('buildId', '', new UID(), 'Build unique ID.', true) + ->param('buildId', '', new UID(), 'Build unique ID.', true) // added as optional param for backward compatibility ->inject('request') ->inject('response') ->inject('dbForProject') @@ -1457,7 +1457,6 @@ App::post('/v1/functions/:functionId/deployments/:deploymentId/build') ->inject('queueForEvents') ->inject('queueForBuilds') ->action(function (string $functionId, string $deploymentId, string $buildId, Request $request, Response $response, Database $dbForProject, Document $project, Event $queueForEvents, Build $queueForBuilds) { - $function = $dbForProject->getDocument('functions', $functionId); if ($function->isEmpty()) { @@ -1470,15 +1469,6 @@ App::post('/v1/functions/:functionId/deployments/:deploymentId/build') throw new Exception(Exception::DEPLOYMENT_NOT_FOUND); } - // buildId is added as param just for backward compatibility - // It is fetched from the deployments collection and not from the request as the user doesn't have to know the buildId - $buildId = $deployment->getAttribute('buildId', ''); - $build = Authorization::skip(fn () => $dbForProject->getDocument('builds', $buildId)); - - if ($build->isEmpty()) { - throw new Exception(Exception::BUILD_NOT_FOUND); - } - $deploymentId = ID::unique(); $deployment->removeAttribute('$internalId');