Remove repository owner
This commit is contained in:
parent
33eb8de9fd
commit
18105d4999
10 changed files with 15 additions and 46 deletions
|
@ -2356,17 +2356,6 @@ $collections = [
|
||||||
'array' => false,
|
'array' => false,
|
||||||
'filters' => []
|
'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'),
|
'$id' => ID::custom('resourceId'),
|
||||||
'type' => Database::VAR_STRING,
|
'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
|
@ -525,14 +525,13 @@ App::put('/v1/functions/:functionId')
|
||||||
->param('installCommand', '', new Text('1028'), 'Install Command.', true)
|
->param('installCommand', '', new Text('1028'), 'Install Command.', true)
|
||||||
->param('installationId', '', new Text(128), 'Appwrite Installation ID for vcs deployment.', 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('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('response')
|
||||||
->inject('dbForProject')
|
->inject('dbForProject')
|
||||||
->inject('project')
|
->inject('project')
|
||||||
->inject('user')
|
->inject('user')
|
||||||
->inject('events')
|
->inject('events')
|
||||||
->inject('dbForConsole')
|
->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);
|
$function = $dbForProject->getDocument('functions', $functionId);
|
||||||
|
|
||||||
|
@ -589,7 +588,6 @@ App::put('/v1/functions/:functionId')
|
||||||
'projectId' => $project->getId(),
|
'projectId' => $project->getId(),
|
||||||
'projectInternalId' => $project->getInternalId(),
|
'projectInternalId' => $project->getInternalId(),
|
||||||
'repositoryId' => $repositoryId,
|
'repositoryId' => $repositoryId,
|
||||||
'repositoryOwner' => $repositoryOwner,
|
|
||||||
'resourceId' => $functionId,
|
'resourceId' => $functionId,
|
||||||
'resourceType' => "function"
|
'resourceType' => "function"
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -5,19 +5,19 @@ use Appwrite\Event\Build;
|
||||||
use Appwrite\Event\Delete;
|
use Appwrite\Event\Delete;
|
||||||
use Utopia\Database\Database;
|
use Utopia\Database\Database;
|
||||||
use Utopia\Database\Document;
|
use Utopia\Database\Document;
|
||||||
use Utopia\Database\Helpers\Permission;
|
|
||||||
use Utopia\Database\Helpers\Role;
|
|
||||||
use Appwrite\Utopia\Request;
|
use Appwrite\Utopia\Request;
|
||||||
use Appwrite\Utopia\Response;
|
use Appwrite\Utopia\Response;
|
||||||
use Utopia\Validator\Text;
|
use Utopia\Validator\Text;
|
||||||
use Utopia\VCS\Adapter\Git\GitHub;
|
use Utopia\VCS\Adapter\Git\GitHub;
|
||||||
use Utopia\Database\Helpers\ID;
|
|
||||||
use Appwrite\Extend\Exception;
|
use Appwrite\Extend\Exception;
|
||||||
use Appwrite\Utopia\Database\Validator\Queries\Installations;
|
use Appwrite\Utopia\Database\Validator\Queries\Installations;
|
||||||
use Utopia\Cache\Adapter\Redis;
|
use Utopia\Cache\Adapter\Redis;
|
||||||
use Utopia\Cache\Cache;
|
use Utopia\Cache\Cache;
|
||||||
use Utopia\Database\Query;
|
use Utopia\Database\Query;
|
||||||
use Utopia\Database\Adapter\MariaDB;
|
use Utopia\Database\Adapter\MariaDB;
|
||||||
|
use Utopia\Database\ID;
|
||||||
|
use Utopia\Database\Permission;
|
||||||
|
use Utopia\Database\Role;
|
||||||
use Utopia\Database\Validator\Authorization;
|
use Utopia\Database\Validator\Authorization;
|
||||||
|
|
||||||
App::get('/v1/vcs/github/installations')
|
App::get('/v1/vcs/github/installations')
|
||||||
|
@ -254,10 +254,9 @@ App::post('/v1/vcs/github/incomingwebhook')
|
||||||
->setType(BUILD_TYPE_DEPLOYMENT)
|
->setType(BUILD_TYPE_DEPLOYMENT)
|
||||||
->setResource($function)
|
->setResource($function)
|
||||||
->setDeployment($deployment)
|
->setDeployment($deployment)
|
||||||
->setProject($project)
|
|
||||||
->setSHA($SHA)
|
|
||||||
->setOwner($owner)
|
|
||||||
->setTargetUrl($targetUrl)
|
->setTargetUrl($targetUrl)
|
||||||
|
->setSHA($SHA)
|
||||||
|
->setProject($project)
|
||||||
->trigger();
|
->trigger();
|
||||||
|
|
||||||
//TODO: Add event?
|
//TODO: Add event?
|
||||||
|
@ -381,7 +380,6 @@ App::post('/v1/vcs/github/incomingwebhook')
|
||||||
->setResource($function)
|
->setResource($function)
|
||||||
->setDeployment($deployment)
|
->setDeployment($deployment)
|
||||||
->setProject($project)
|
->setProject($project)
|
||||||
->setOwner($owner)
|
|
||||||
->trigger();
|
->trigger();
|
||||||
|
|
||||||
//TODO: Add event?
|
//TODO: Add event?
|
||||||
|
|
|
@ -45,14 +45,13 @@ class BuildsV1 extends Worker
|
||||||
$resource = new Document($this->args['resource'] ?? []);
|
$resource = new Document($this->args['resource'] ?? []);
|
||||||
$deployment = new Document($this->args['deployment'] ?? []);
|
$deployment = new Document($this->args['deployment'] ?? []);
|
||||||
$SHA = $this->args['SHA'] ?? '';
|
$SHA = $this->args['SHA'] ?? '';
|
||||||
$owner = $this->args['owner'] ?? '';
|
|
||||||
$targetUrl = $this->args['targetUrl'] ?? '';
|
$targetUrl = $this->args['targetUrl'] ?? '';
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case BUILD_TYPE_DEPLOYMENT:
|
case BUILD_TYPE_DEPLOYMENT:
|
||||||
case BUILD_TYPE_RETRY:
|
case BUILD_TYPE_RETRY:
|
||||||
Console::info('Creating build for deployment: ' . $deployment->getId());
|
Console::info('Creating build for deployment: ' . $deployment->getId());
|
||||||
$this->buildDeployment($project, $resource, $deployment, $SHA, $owner, $targetUrl);
|
$this->buildDeployment($project, $resource, $deployment, $SHA, $targetUrl);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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;
|
global $register;
|
||||||
|
|
||||||
|
@ -109,7 +108,6 @@ class BuildsV1 extends Worker
|
||||||
$vcsRepos = Authorization::skip(fn () => $dbForConsole
|
$vcsRepos = Authorization::skip(fn () => $dbForConsole
|
||||||
->getDocument('vcs_repos', $vcsRepoId));
|
->getDocument('vcs_repos', $vcsRepoId));
|
||||||
$repositoryId = $vcsRepos->getAttribute('repositoryId');
|
$repositoryId = $vcsRepos->getAttribute('repositoryId');
|
||||||
$owner = $vcsRepos->getAttribute('repositoryOwner');
|
|
||||||
$vcsInstallations = Authorization::skip(fn () => $dbForConsole
|
$vcsInstallations = Authorization::skip(fn () => $dbForConsole
|
||||||
->getDocument('vcs_installations', $vcsInstallationId));
|
->getDocument('vcs_installations', $vcsInstallationId));
|
||||||
$installationId = $vcsInstallations->getAttribute('installationId');
|
$installationId = $vcsInstallations->getAttribute('installationId');
|
||||||
|
@ -119,6 +117,7 @@ class BuildsV1 extends Worker
|
||||||
|
|
||||||
$github = new GitHub();
|
$github = new GitHub();
|
||||||
$github->initialiseVariables($installationId, $privateKey, $githubAppId);
|
$github->initialiseVariables($installationId, $privateKey, $githubAppId);
|
||||||
|
$owner = $github->getOwnerName($installationId);
|
||||||
$repositoryName = $github->getRepositoryName($repositoryId);
|
$repositoryName = $github->getRepositoryName($repositoryId);
|
||||||
$branchName = $deployment->getAttribute('branch');
|
$branchName = $deployment->getAttribute('branch');
|
||||||
$gitCloneCommand = $github->generateGitCloneCommand($owner, $repositoryId, $branchName);
|
$gitCloneCommand = $github->generateGitCloneCommand($owner, $repositoryId, $branchName);
|
||||||
|
|
4
composer.lock
generated
4
composer.lock
generated
|
@ -3090,7 +3090,7 @@
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/utopia-php/vcs.git",
|
"url": "https://github.com/utopia-php/vcs.git",
|
||||||
"reference": "774b6424a6d2d186d9713e863384857e3bb6ca0a"
|
"reference": "a3f5d680e79431b661bde03774b8c4e4d71e6023"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"adhocore/jwt": "^1.1",
|
"adhocore/jwt": "^1.1",
|
||||||
|
@ -3134,7 +3134,7 @@
|
||||||
"utopia",
|
"utopia",
|
||||||
"vcs"
|
"vcs"
|
||||||
],
|
],
|
||||||
"time": "2023-05-22T10:27:30+00:00"
|
"time": "2023-05-22T12:56:31+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "utopia-php/websocket",
|
"name": "utopia-php/websocket",
|
||||||
|
|
|
@ -11,7 +11,6 @@ class Build extends Event
|
||||||
protected ?Document $resource = null;
|
protected ?Document $resource = null;
|
||||||
protected ?Document $deployment = null;
|
protected ?Document $deployment = null;
|
||||||
protected string $SHA = '';
|
protected string $SHA = '';
|
||||||
protected string $owner = '';
|
|
||||||
protected string $targetUrl = '';
|
protected string $targetUrl = '';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
@ -32,19 +31,6 @@ class Build extends Event
|
||||||
return $this;
|
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
|
* Sets redirect target url for the deployment
|
||||||
*
|
*
|
||||||
|
@ -141,7 +127,6 @@ class Build extends Event
|
||||||
'deployment' => $this->deployment,
|
'deployment' => $this->deployment,
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
'SHA' => $this->SHA,
|
'SHA' => $this->SHA,
|
||||||
'owner' => $this->owner,
|
|
||||||
'targetUrl' => $this->targetUrl
|
'targetUrl' => $this->targetUrl
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue