1
0
Fork 0
mirror of synced 2024-07-04 06:00:53 +12:00

Remove repository owner

This commit is contained in:
Matej Bačo 2023-05-22 15:02:55 +02:00
parent 33eb8de9fd
commit 18105d4999
10 changed files with 15 additions and 46 deletions

View file

@ -2356,17 +2356,6 @@ $collections = [
'array' => false,
'filters' => []
],
[
'$id' => ID::custom('repositoryOwner'),
'type' => Database::VAR_STRING,
'format' => '',
'size' => 128,
'signed' => true,
'required' => true,
'default' => null,
'array' => false,
'filters' => []
],
[
'$id' => ID::custom('resourceId'),
'type' => Database::VAR_STRING,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -525,14 +525,13 @@ App::put('/v1/functions/:functionId')
->param('installCommand', '', new Text('1028'), 'Install Command.', true)
->param('installationId', '', new Text(128), 'Appwrite Installation ID for vcs deployment.', true)
->param('repositoryId', '', new Text(128), 'Repository ID of the repo linked to the function', true)
->param('repositoryOwner', '', new Text(128), 'Repository Owner of the repo linked to the function', true)
->inject('response')
->inject('dbForProject')
->inject('project')
->inject('user')
->inject('events')
->inject('dbForConsole')
->action(function (string $functionId, string $name, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $buildCommand, string $installCommand, string $vcsInstallationId, string $repositoryId, string $repositoryOwner, Response $response, Database $dbForProject, Document $project, Document $user, Event $eventsInstance, Database $dbForConsole) {
->action(function (string $functionId, string $name, array $execute, array $events, string $schedule, int $timeout, bool $enabled, bool $logging, string $entrypoint, string $buildCommand, string $installCommand, string $vcsInstallationId, string $repositoryId, Response $response, Database $dbForProject, Document $project, Document $user, Event $eventsInstance, Database $dbForConsole) {
$function = $dbForProject->getDocument('functions', $functionId);
@ -589,7 +588,6 @@ App::put('/v1/functions/:functionId')
'projectId' => $project->getId(),
'projectInternalId' => $project->getInternalId(),
'repositoryId' => $repositoryId,
'repositoryOwner' => $repositoryOwner,
'resourceId' => $functionId,
'resourceType' => "function"
]);

View file

@ -5,19 +5,19 @@ use Appwrite\Event\Build;
use Appwrite\Event\Delete;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Appwrite\Utopia\Request;
use Appwrite\Utopia\Response;
use Utopia\Validator\Text;
use Utopia\VCS\Adapter\Git\GitHub;
use Utopia\Database\Helpers\ID;
use Appwrite\Extend\Exception;
use Appwrite\Utopia\Database\Validator\Queries\Installations;
use Utopia\Cache\Adapter\Redis;
use Utopia\Cache\Cache;
use Utopia\Database\Query;
use Utopia\Database\Adapter\MariaDB;
use Utopia\Database\ID;
use Utopia\Database\Permission;
use Utopia\Database\Role;
use Utopia\Database\Validator\Authorization;
App::get('/v1/vcs/github/installations')
@ -254,10 +254,9 @@ App::post('/v1/vcs/github/incomingwebhook')
->setType(BUILD_TYPE_DEPLOYMENT)
->setResource($function)
->setDeployment($deployment)
->setProject($project)
->setSHA($SHA)
->setOwner($owner)
->setTargetUrl($targetUrl)
->setSHA($SHA)
->setProject($project)
->trigger();
//TODO: Add event?
@ -381,7 +380,6 @@ App::post('/v1/vcs/github/incomingwebhook')
->setResource($function)
->setDeployment($deployment)
->setProject($project)
->setOwner($owner)
->trigger();
//TODO: Add event?

View file

@ -45,14 +45,13 @@ class BuildsV1 extends Worker
$resource = new Document($this->args['resource'] ?? []);
$deployment = new Document($this->args['deployment'] ?? []);
$SHA = $this->args['SHA'] ?? '';
$owner = $this->args['owner'] ?? '';
$targetUrl = $this->args['targetUrl'] ?? '';
switch ($type) {
case BUILD_TYPE_DEPLOYMENT:
case BUILD_TYPE_RETRY:
Console::info('Creating build for deployment: ' . $deployment->getId());
$this->buildDeployment($project, $resource, $deployment, $SHA, $owner, $targetUrl);
$this->buildDeployment($project, $resource, $deployment, $SHA, $targetUrl);
break;
default:
@ -61,7 +60,7 @@ class BuildsV1 extends Worker
}
}
protected function buildDeployment(Document $project, Document $function, Document $deployment, string $SHA = '', string $owner = '', string $targetUrl = '')
protected function buildDeployment(Document $project, Document $function, Document $deployment, string $SHA = '', string $targetUrl = '')
{
global $register;
@ -109,7 +108,6 @@ class BuildsV1 extends Worker
$vcsRepos = Authorization::skip(fn () => $dbForConsole
->getDocument('vcs_repos', $vcsRepoId));
$repositoryId = $vcsRepos->getAttribute('repositoryId');
$owner = $vcsRepos->getAttribute('repositoryOwner');
$vcsInstallations = Authorization::skip(fn () => $dbForConsole
->getDocument('vcs_installations', $vcsInstallationId));
$installationId = $vcsInstallations->getAttribute('installationId');
@ -119,6 +117,7 @@ class BuildsV1 extends Worker
$github = new GitHub();
$github->initialiseVariables($installationId, $privateKey, $githubAppId);
$owner = $github->getOwnerName($installationId);
$repositoryName = $github->getRepositoryName($repositoryId);
$branchName = $deployment->getAttribute('branch');
$gitCloneCommand = $github->generateGitCloneCommand($owner, $repositoryId, $branchName);

4
composer.lock generated
View file

@ -3090,7 +3090,7 @@
"source": {
"type": "git",
"url": "https://github.com/utopia-php/vcs.git",
"reference": "774b6424a6d2d186d9713e863384857e3bb6ca0a"
"reference": "a3f5d680e79431b661bde03774b8c4e4d71e6023"
},
"require": {
"adhocore/jwt": "^1.1",
@ -3134,7 +3134,7 @@
"utopia",
"vcs"
],
"time": "2023-05-22T10:27:30+00:00"
"time": "2023-05-22T12:56:31+00:00"
},
{
"name": "utopia-php/websocket",

View file

@ -11,7 +11,6 @@ class Build extends Event
protected ?Document $resource = null;
protected ?Document $deployment = null;
protected string $SHA = '';
protected string $owner = '';
protected string $targetUrl = '';
public function __construct()
@ -32,19 +31,6 @@ class Build extends Event
return $this;
}
/**
* Sets repository owner name for the build event.
*
* @param string $owner is the name of the repository owner
* @return self
*/
public function setOwner(string $owner): self
{
$this->owner = $owner;
return $this;
}
/**
* Sets redirect target url for the deployment
*
@ -141,7 +127,6 @@ class Build extends Event
'deployment' => $this->deployment,
'type' => $this->type,
'SHA' => $this->SHA,
'owner' => $this->owner,
'targetUrl' => $this->targetUrl
]);
}