Call VCS factory directly instead of via closure wrapper

vcsForInstallation/vcsForProvider were 1:1 passthrough closures around
VcsFactory::fromInstallation()/fromProvider() with no resolution logic
of their own, unlike getProjectDB which does real per-request work.
Inject vcsFactory and call it directly at each site instead.
This commit is contained in:
harsh mahajan committed 2026-07-14 11:21:26 +05:30
1 parent 8a12d98705
commit a4af55815d
20 files changed
+95 -86

No files matched your search

+4 -3
View File
@@ -5,6 +5,7 @@ global $utopia, $request, $response;
use Appwrite\Extend\Exception;
use Appwrite\Utopia\Request;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use Utopia\Config\Config;
use Utopia\Database\Database;
use Utopia\Database\Document;
@@ -238,11 +239,11 @@ Http::get('/v1/mock/github/callback')
->label('docs', false)
->param('providerInstallationId', '', new UID(), 'GitHub installation ID')
->param('projectId', '', new UID(), 'Project ID of the project where app is to be installed')
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('project')
->inject('response')
->inject('dbForPlatform')
->action(function (string $providerInstallationId, string $projectId, callable $vcsForInstallation, Document $project, Response $response, Database $dbForPlatform) {
->action(function (string $providerInstallationId, string $projectId, VcsFactory $vcsFactory, Document $project, Response $response, Database $dbForPlatform) {
$isDevelopment = System::getEnv('_APP_ENV', 'development') === 'development';
if (!$isDevelopment) {
@@ -260,7 +261,7 @@ Http::get('/v1/mock/github/callback')
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Missing provider installation ID');
}
$vcs = $vcsForInstallation(new Document([
$vcs = $vcsFactory->fromInstallation(new Document([
'provider' => 'github',
'providerInstallationId' => $providerInstallationId,
]));
-4
View File
@@ -380,10 +380,6 @@ $container->set('vcsFactory', fn (Cache $cache) => new VcsFactory($cache), ['cac
$container->set('vcsProviders', fn (VcsFactory $vcsFactory) => fn () => $vcsFactory->getProviders(), ['vcsFactory']);
$container->set('vcsForInstallation', fn (VcsFactory $vcsFactory) => fn (Document $installation) => $vcsFactory->fromInstallation($installation), ['vcsFactory']);
$container->set('vcsForProvider', fn (VcsFactory $vcsFactory) => fn (string $provider) => $vcsFactory->fromProvider($provider), ['vcsFactory']);
$container->set('vcsWebhookSecret', fn (VcsFactory $vcsFactory) => fn (string $provider) => $vcsFactory->getWebhookSecret($provider), ['vcsFactory']);
$container->set('plan', fn () => []);
@@ -13,6 +13,7 @@ use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use OpenRuntimes\Orchestrator\Jobs;
use Utopia\Database\Database;
use Utopia\Database\Document;
@@ -83,8 +84,7 @@ class Create extends Base
->inject('queueForEvents')
->inject('project')
->inject('publisherForBuilds')
->inject('vcsForInstallation')
->inject('vcsForProvider')
->inject('vcsFactory')
->inject('jobs')
->inject('authorization')
->inject('platform')
@@ -106,8 +106,7 @@ class Create extends Base
Event $queueForEvents,
Document $project,
BuildPublisher $publisherForBuilds,
callable $vcsForInstallation,
callable $vcsForProvider,
VcsFactory $vcsFactory,
Jobs $jobs,
Authorization $authorization,
array $platform
@@ -145,7 +144,7 @@ class Create extends Base
dbForProject: $dbForProject,
publisherForBuilds: $publisherForBuilds,
template: $template,
vcs: $vcsForInstallation($installation),
vcs: $vcsFactory->fromInstallation($installation),
activate: $activate,
platform: $platform,
referenceType: $type,
@@ -204,7 +203,7 @@ class Create extends Base
try {
// Templates are public github.com repositories regardless of
// the function's own provider.
$tags = $vcsForProvider('github')->listTags($owner, $repository, $reference);
$tags = $vcsFactory->fromProvider('github')->listTags($owner, $repository, $reference);
$ref = \end($tags) ?: $reference;
} catch (\Throwable) {
// Fall back to the raw reference; the build surfaces a bad ref.
@@ -11,6 +11,7 @@ use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use OpenRuntimes\Orchestrator\Jobs;
use Utopia\Database\Database;
use Utopia\Database\Document;
@@ -73,7 +74,7 @@ class Create extends Base
->inject('project')
->inject('queueForEvents')
->inject('publisherForBuilds')
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('jobs')
->inject('platform')
->callback($this->action(...));
@@ -91,7 +92,7 @@ class Create extends Base
Document $project,
Event $queueForEvents,
BuildPublisher $publisherForBuilds,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Jobs $jobs,
array $platform,
) {
@@ -117,7 +118,7 @@ class Create extends Base
dbForProject: $dbForProject,
publisherForBuilds: $publisherForBuilds,
template: $template,
vcs: $vcsForInstallation($installation),
vcs: $vcsFactory->fromInstallation($installation),
activate: $activate,
platform: $platform,
reference: $reference,
@@ -20,6 +20,7 @@ use Appwrite\Task\Validator\Cron;
use Appwrite\Utopia\Database\Validator\CustomId;
use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Model\Rule;
use Appwrite\Vcs\Factory as VcsFactory;
use OpenRuntimes\Orchestrator\Jobs;
use Utopia\Abuse\Abuse;
use Utopia\Config\Config;
@@ -129,7 +130,7 @@ class Create extends Base
->inject('publisherForFunctions')
->inject('dbForPlatform')
->inject('request')
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('authorization')
->inject('platform')
->callback($this->action(...));
@@ -174,7 +175,7 @@ class Create extends Base
FunctionPublisher $publisherForFunctions,
Database $dbForPlatform,
Request $request,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Authorization $authorization,
array $platform
) {
@@ -347,7 +348,7 @@ class Create extends Base
publisherForBuilds: $publisherForBuilds,
jobs: $jobs,
template: $template,
vcs: $vcsForInstallation($installation),
vcs: $vcsFactory->fromInstallation($installation),
activate: true,
platform: $platform,
reference: $providerBranch,
@@ -13,6 +13,7 @@ use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Task\Validator\Cron;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use Executor\Executor;
use OpenRuntimes\Orchestrator\Jobs;
use Utopia\Config\Config;
@@ -113,7 +114,7 @@ class Update extends Base
->inject('publisherForBuilds')
->inject('jobs')
->inject('dbForPlatform')
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('executor')
->inject('authorization')
->inject('platform')
@@ -151,7 +152,7 @@ class Update extends Base
BuildPublisher $publisherForBuilds,
Jobs $jobs,
Database $dbForPlatform,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Executor $executor,
Authorization $authorization,
array $platform
@@ -311,7 +312,7 @@ class Update extends Base
// Redeploy logic
if (!$isConnected && !empty($providerRepositoryId)) {
$this->redeployVcsFunction($request, $function, $project, $installation, $dbForProject, $publisherForBuilds, new Document(), $vcsForInstallation($installation), true, $platform, jobs: $jobs);
$this->redeployVcsFunction($request, $function, $project, $installation, $dbForProject, $publisherForBuilds, new Document(), $vcsFactory->fromInstallation($installation), true, $platform, jobs: $jobs);
}
// Inform scheduler if function is still active
@@ -17,6 +17,7 @@ use Appwrite\Usage\Build as BuildUsage;
use Appwrite\Usage\Context;
use Appwrite\Utopia\Response\Model\Deployment;
use Appwrite\Vcs\Comment;
use Appwrite\Vcs\Factory as VcsFactory;
use Exception;
use Executor\Exception as ExecutorException;
use Executor\Exception\Timeout as ExecutorTimeout;
@@ -91,8 +92,7 @@ class Builds extends Action
->inject('queueForRealtime')
->inject('usage')
->inject('publisherForUsage')
->inject('vcsForProvider')
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('dbForProject')
->inject('deviceForFunctions')
->inject('deviceForSites')
@@ -119,8 +119,7 @@ class Builds extends Action
Realtime $queueForRealtime,
Context $usage,
UsagePublisher $publisherForUsage,
callable $vcsForProvider,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Database $dbForProject,
Device $deviceForFunctions,
Device $deviceForSites,
@@ -151,7 +150,7 @@ class Builds extends Action
switch ($type) {
case BUILD_TYPE_DEPLOYMENT:
case BUILD_TYPE_RETRY:
$templateVcs = $vcsForProvider('github');
$templateVcs = $vcsFactory->fromProvider('github');
$this->buildDeployment(
$deviceForFunctions,
$deviceForSites,
@@ -166,7 +165,7 @@ class Builds extends Action
$dbForPlatform,
$dbForProject,
$templateVcs,
$vcsForInstallation,
$vcsFactory,
$project,
$resource,
$deployment,
@@ -204,7 +203,7 @@ class Builds extends Action
Database $dbForPlatform,
Database $dbForProject,
Git $templateVcs,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Document $project,
Document $resource,
Document $deployment,
@@ -325,7 +324,7 @@ class Builds extends Action
$providerInstallationId = $installation->getAttribute('providerInstallationId');
try {
$providerAdapter = $vcsForInstallation($installation);
$providerAdapter = $vcsFactory->fromInstallation($installation);
} catch (\Exception $e) {
if ($e->getCode() === 404
&& $resource->getAttribute('installationId', '') === $installationId) {
@@ -13,6 +13,7 @@ use Appwrite\Event\Webhook;
use Appwrite\Usage\Build as BuildUsage;
use Appwrite\Usage\Context as UsageContext;
use Appwrite\Utopia\Response\Model\Deployment;
use Appwrite\Vcs\Factory as VcsFactory;
use Utopia\Cache\Cache;
use Utopia\Database\Database;
use Utopia\Database\DateTime;
@@ -63,7 +64,7 @@ class Jobs extends Action
->inject('publisherForUsage')
->inject('usage')
->inject('deviceForBuilds')
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('cache')
->inject('locks')
->callback($this->action(...));
@@ -81,7 +82,7 @@ class Jobs extends Action
UsagePublisher $publisherForUsage,
UsageContext $usage,
Device $deviceForBuilds,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Cache $cache,
callable $locks,
): void {
@@ -92,7 +93,7 @@ class Jobs extends Action
return;
}
$locks('jobs-deployment:' . $deploymentId, self::LOCK_TTL, function () use ($event, $project, $dbForProject, $dbForPlatform, $queueForRealtime, $queueForEvents, $queueForWebhooks, $publisherForFunctions, $publisherForUsage, $usage, $deviceForBuilds, $vcsForInstallation, $cache, $deploymentId): void {
$locks('jobs-deployment:' . $deploymentId, self::LOCK_TTL, function () use ($event, $project, $dbForProject, $dbForPlatform, $queueForRealtime, $queueForEvents, $queueForWebhooks, $publisherForFunctions, $publisherForUsage, $usage, $deviceForBuilds, $vcsFactory, $cache, $deploymentId): void {
if ($event->id !== '') {
$key = 'jobs-event-' . $event->id;
if ($cache->load($key, self::DEDUPE_TTL) !== false) {
@@ -113,7 +114,7 @@ class Jobs extends Action
$deployment = match ($event->event) {
'orchestrator.job.log' => $this->onLog($dbForProject, $deployment, $event->data),
'orchestrator.job.artifact' => $this->onArtifact($dbForProject, $deployment, $event->data),
'orchestrator.job.exit' => $this->onExit($dbForProject, $dbForPlatform, $project, $deployment, (int) ($event->data['exitCode'] ?? 0), $usage, $publisherForUsage, $deviceForBuilds, $vcsForInstallation),
'orchestrator.job.exit' => $this->onExit($dbForProject, $dbForPlatform, $project, $deployment, (int) ($event->data['exitCode'] ?? 0), $usage, $publisherForUsage, $deviceForBuilds, $vcsFactory),
default => $deployment,
};
@@ -202,10 +203,10 @@ class Jobs extends Action
UsageContext $usage,
UsagePublisher $publisherForUsage,
Device $deviceForBuilds,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
): Document {
if ($exitCode !== 0) {
return $this->finalize($dbForProject, $dbForPlatform, $project, $deployment, false, "Build failed with exit code {$exitCode}.", $usage, $publisherForUsage, $vcsForInstallation);
return $this->finalize($dbForProject, $dbForPlatform, $project, $deployment, false, "Build failed with exit code {$exitCode}.", $usage, $publisherForUsage, $vcsFactory);
}
$path = Job::buildPath($project->getId(), $deployment->getId());
@@ -214,10 +215,10 @@ class Jobs extends Action
$limit = (int) System::getEnv('_APP_COMPUTE_BUILD_SIZE_LIMIT', '2000000000');
if ($limit !== 0 && $size > $limit) {
$deviceForBuilds->delete($path);
return $this->finalize($dbForProject, $dbForPlatform, $project, $deployment, false, 'Build size should be less than ' . \number_format($limit / (1000 * 1000), 2) . ' MBs.', $usage, $publisherForUsage, $vcsForInstallation);
return $this->finalize($dbForProject, $dbForPlatform, $project, $deployment, false, 'Build size should be less than ' . \number_format($limit / (1000 * 1000), 2) . ' MBs.', $usage, $publisherForUsage, $vcsFactory);
}
return $this->finalize($dbForProject, $dbForPlatform, $project, $deployment, true, '', $usage, $publisherForUsage, $vcsForInstallation, $size);
return $this->finalize($dbForProject, $dbForPlatform, $project, $deployment, true, '', $usage, $publisherForUsage, $vcsFactory, $size);
}
/**
@@ -234,7 +235,7 @@ class Jobs extends Action
string $message,
UsageContext $usage,
UsagePublisher $publisherForUsage,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
int $buildSize = 0,
): Document {
$function = $dbForProject->getDocument('functions', $deployment->getAttribute('resourceId'));
@@ -287,7 +288,7 @@ class Jobs extends Action
// deployments only; best-effort). "pending" at build start is a follow-up.
$status = $deployment->getAttribute('status');
if (\in_array($status, ['ready', 'failed'], true) && ! $function->isEmpty()) {
$this->gitStatus($vcsForInstallation, $dbForPlatform, $project, $function, $deployment, $status === 'ready' ? 'success' : 'failure');
$this->gitStatus($vcsFactory, $dbForPlatform, $project, $function, $deployment, $status === 'ready' ? 'success' : 'failure');
}
return $deployment;
@@ -297,7 +298,7 @@ class Jobs extends Action
* Post a VCS commit status for a VCS deployment (no-op for non-VCS builds
* or silent mode). Best-effort — a failed status update never fails the build.
*/
private function gitStatus(callable $vcsForInstallation, Database $dbForPlatform, Document $project, Document $function, Document $deployment, string $state): void
private function gitStatus(VcsFactory $vcsFactory, Database $dbForPlatform, Document $project, Document $function, Document $deployment, string $state): void
{
$commitHash = $deployment->getAttribute('providerCommitHash', '');
if ($commitHash === '' || $function->getAttribute('providerSilentMode', false) === true) {
@@ -310,7 +311,7 @@ class Jobs extends Action
if ($providerInstallationId === '') {
return;
}
$vcs = $vcsForInstallation($installation);
$vcs = $vcsFactory->fromInstallation($installation);
$protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https';
$hostname = System::getEnv('_APP_CONSOLE_DOMAIN', System::getEnv('_APP_DOMAIN', ''));
@@ -12,6 +12,7 @@ use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Helpers\ID;
@@ -81,7 +82,7 @@ class Create extends Base
->inject('project')
->inject('queueForEvents')
->inject('publisherForBuilds')
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('authorization')
->inject('platform')
->callback($this->action(...));
@@ -102,7 +103,7 @@ class Create extends Base
Document $project,
Event $queueForEvents,
BuildPublisher $publisherForBuilds,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Authorization $authorization,
array $platform
) {
@@ -135,7 +136,7 @@ class Create extends Base
dbForPlatform: $dbForPlatform,
publisherForBuilds: $publisherForBuilds,
template: $template,
vcs: $vcsForInstallation($installation),
vcs: $vcsFactory->fromInstallation($installation),
activate: $activate,
authorization: $authorization,
platform: $platform
@@ -11,6 +11,7 @@ use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Validator\Authorization;
@@ -73,7 +74,7 @@ class Create extends Base
->inject('project')
->inject('queueForEvents')
->inject('publisherForBuilds')
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('authorization')
->inject('platform')
->callback($this->action(...));
@@ -91,7 +92,7 @@ class Create extends Base
Document $project,
Event $queueForEvents,
BuildPublisher $publisherForBuilds,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Authorization $authorization,
array $platform
) {
@@ -118,7 +119,7 @@ class Create extends Base
dbForPlatform: $dbForPlatform,
publisherForBuilds: $publisherForBuilds,
template: $template,
vcs: $vcsForInstallation($installation),
vcs: $vcsFactory->fromInstallation($installation),
activate: $activate,
authorization: $authorization,
reference: $reference,
@@ -11,6 +11,7 @@ use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use Executor\Executor;
use Utopia\Config\Config;
use Utopia\Database\Database;
@@ -107,7 +108,7 @@ class Update extends Base
->inject('queueForEvents')
->inject('publisherForBuilds')
->inject('dbForPlatform')
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('executor')
->inject('platform')
->callback($this->action(...));
@@ -144,7 +145,7 @@ class Update extends Base
Event $queueForEvents,
BuildPublisher $publisherForBuilds,
Database $dbForPlatform,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Executor $executor,
array $platform
) {
@@ -314,7 +315,7 @@ class Update extends Base
// Redeploy logic
if (!$isConnected && !empty($providerRepositoryId)) {
$this->redeployVcsFunction($request, $site, $project, $installation, $dbForProject, $publisherForBuilds, new Document(), $vcsForInstallation($installation), true, $platform);
$this->redeployVcsFunction($request, $site, $project, $installation, $dbForProject, $publisherForBuilds, new Document(), $vcsFactory->fromInstallation($installation), true, $platform);
}
$queueForEvents->setParam('siteId', $site->getId());
@@ -10,6 +10,7 @@ use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use OpenRuntimes\Orchestrator\Jobs;
use Utopia\Database\Database;
use Utopia\Database\Document;
@@ -53,7 +54,7 @@ class Update extends Action
->param('installationId', '', new Text(256), 'Installation Id')
->param('repositoryId', '', new Text(256), 'VCS Repository Id')
->param('providerPullRequestId', '', new Text(256), 'GitHub Pull Request Id')
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('response')
->inject('project')
->inject('dbForPlatform')
@@ -69,7 +70,7 @@ class Update extends Action
string $installationId,
string $repositoryId,
string $providerPullRequestId,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Response $response,
Document $project,
Database $dbForPlatform,
@@ -103,7 +104,7 @@ class Update extends Action
$repository = $authorization->skip(fn () => $dbForPlatform->updateDocument('repositories', $repository->getId(), new Document(['providerPullRequestIds' => $providerPullRequestIds])));
$providerInstallationId = $installation->getAttribute('providerInstallationId');
$vcs = $vcsForInstallation($installation);
$vcs = $vcsFactory->fromInstallation($installation);
$repositories = [$repository];
$providerRepositoryId = $repository->getAttribute('providerRepositoryId');
@@ -6,6 +6,7 @@ use Appwrite\Auth\OAuth2\Github as OAuth2Github;
use Appwrite\Extend\Exception;
use Appwrite\Platform\Permission as AppwritePermission;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use Utopia\Database\Database;
use Utopia\Database\DateTime;
use Utopia\Database\Document;
@@ -39,7 +40,7 @@ class Get extends Action
->param('setup_action', '', new Text(256, 0), 'GitHub setup action type', true)
->param('state', '', new Text(2048), 'GitHub state. Contains info sent when starting authorization flow.', true)
->param('code', '', new Text(2048, 0), 'OAuth2 code. This is a temporary code that the will be later exchanged for an access token.', true)
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('project')
->inject('response')
->inject('dbForPlatform')
@@ -52,7 +53,7 @@ class Get extends Action
string $setupAction,
string $state,
string $code,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Document $project,
Response $response,
Database $dbForPlatform,
@@ -100,7 +101,7 @@ class Get extends Action
// Create / Update installation
if (!empty($providerInstallationId)) {
$vcs = $vcsForInstallation(new Document([
$vcs = $vcsFactory->fromInstallation(new Document([
'provider' => 'github',
'providerInstallationId' => $providerInstallationId,
]));
@@ -8,6 +8,7 @@ use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\VCS\Http\GitHub\Deployment;
use Appwrite\Utopia\Request;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use OpenRuntimes\Orchestrator\Jobs;
use Utopia\Console;
use Utopia\Database\Database;
@@ -37,8 +38,7 @@ class Create extends Action
->groups(['api', 'vcs'])
->label('scope', 'public')
->inject('vcsWebhookSecret')
->inject('vcsForProvider')
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('request')
->inject('response')
->inject('dbForPlatform')
@@ -52,8 +52,7 @@ class Create extends Action
public function action(
callable $vcsWebhookSecret,
callable $vcsForProvider,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Request $request,
Response $response,
Database $dbForPlatform,
@@ -65,7 +64,7 @@ class Create extends Action
) {
$this->preprocessEvent($request);
$vcs = $vcsForProvider('github');
$vcs = $vcsFactory->fromProvider('github');
$event = $request->getHeaderLine('x-github-event', '');
Span::add('vcs.github.event.name', $event);
@@ -85,8 +84,8 @@ class Create extends Action
match ($event) {
GitHub::EVENT_INSTALLATION => $this->handleInstallationEvent($parsedPayload, $dbForPlatform, $authorization, $getProjectDB),
GitHub::EVENT_PUSH => $this->handlePushEvent($parsedPayload, $vcsForInstallation, $dbForPlatform, $authorization, $publisherForBuilds, $getProjectDB, $platform, $jobs),
GitHub::EVENT_PULL_REQUEST => $this->handlePullRequestEvent($parsedPayload, $vcsForInstallation, $dbForPlatform, $authorization, $publisherForBuilds, $getProjectDB, $platform, $jobs),
GitHub::EVENT_PUSH => $this->handlePushEvent($parsedPayload, $vcsFactory, $dbForPlatform, $authorization, $publisherForBuilds, $getProjectDB, $platform, $jobs),
GitHub::EVENT_PULL_REQUEST => $this->handlePullRequestEvent($parsedPayload, $vcsFactory, $dbForPlatform, $authorization, $publisherForBuilds, $getProjectDB, $platform, $jobs),
default => null,
};
@@ -185,7 +184,7 @@ class Create extends Action
private function handlePushEvent(
array $parsedPayload,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Database $dbForPlatform,
Authorization $authorization,
BuildPublisher $publisherForBuilds,
@@ -213,7 +212,7 @@ class Create extends Action
Span::add('vcs.github.event.branch', $providerBranch);
Span::add('vcs.github.event.installation.id', $providerInstallationId);
$vcs = $vcsForInstallation(new Document([
$vcs = $vcsFactory->fromInstallation(new Document([
'provider' => 'github',
'providerInstallationId' => $providerInstallationId,
]));
@@ -233,7 +232,7 @@ class Create extends Action
private function handlePullRequestEvent(
array $parsedPayload,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Database $dbForPlatform,
Authorization $authorization,
BuildPublisher $publisherForBuilds,
@@ -267,7 +266,7 @@ class Create extends Action
return;
}
$vcs = $vcsForInstallation(new Document([
$vcs = $vcsFactory->fromInstallation(new Document([
'provider' => 'github',
'providerInstallationId' => $providerInstallationId,
]));
@@ -9,6 +9,7 @@ use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Database\Validator\Queries\Branches;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Exception\Query as QueryException;
@@ -53,7 +54,7 @@ class XList extends Action
->param('providerRepositoryId', '', new Text(256), 'Repository Id')
->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true)
->param('queries', [], new Branches(), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit, offset, cursorAfter, and cursorBefore', true)
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('response')
->inject('dbForPlatform')
->callback($this->action(...));
@@ -64,7 +65,7 @@ class XList extends Action
string $providerRepositoryId,
string $search,
array $queries,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Response $response,
Database $dbForPlatform
) {
@@ -81,7 +82,7 @@ class XList extends Action
}
$providerInstallationId = $installation->getAttribute('providerInstallationId');
$vcs = $vcsForInstallation($installation);
$vcs = $vcsFactory->fromInstallation($installation);
$owner = $vcs->getOwnerName($providerInstallationId);
try {
@@ -8,6 +8,7 @@ use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Platform\Scope\HTTP;
@@ -49,7 +50,7 @@ class Get extends Action
->param('providerRepositoryId', '', new Text(256), 'Repository Id')
->param('providerRootDirectory', '', new Text(256, 0), 'Path to get contents of nested directory', true)
->param('providerReference', '', new Text(256, 0), 'Git reference (branch, tag, commit) to get contents from', true)
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('response')
->inject('dbForPlatform')
->callback($this->action(...));
@@ -60,7 +61,7 @@ class Get extends Action
string $providerRepositoryId,
string $providerRootDirectory,
string $providerReference,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Response $response,
Database $dbForPlatform
) {
@@ -71,7 +72,7 @@ class Get extends Action
}
$providerInstallationId = $installation->getAttribute('providerInstallationId');
$vcs = $vcsForInstallation($installation);
$vcs = $vcsFactory->fromInstallation($installation);
$owner = $vcs->getOwnerName($providerInstallationId);
try {
@@ -9,6 +9,7 @@ use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use Utopia\Database\Database;
use Utopia\Database\DateTime;
use Utopia\Database\Document;
@@ -52,7 +53,7 @@ class Create extends Action
->param('installationId', '', new Text(256), 'Installation Id')
->param('name', '', new Text(256), 'Repository name (slug)')
->param('private', '', new Boolean(false), 'Mark repository public or private')
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('user')
->inject('response')
->inject('dbForPlatform')
@@ -63,7 +64,7 @@ class Create extends Action
string $installationId,
string $name,
bool $private,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Document $user,
Response $response,
Database $dbForPlatform
@@ -127,7 +128,7 @@ class Create extends Action
}
} else {
$providerInstallationId = $installation->getAttribute('providerInstallationId');
$vcs = $vcsForInstallation($installation);
$vcs = $vcsFactory->fromInstallation($installation);
$owner = $vcs->getOwnerName($providerInstallationId);
try {
@@ -8,6 +8,7 @@ use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use Swoole\Coroutine\WaitGroup;
use Utopia\Config\Adapters\Dotenv as ConfigDotenv;
use Utopia\Config\Config;
@@ -92,7 +93,7 @@ class Create extends Action
->param('providerRepositoryId', '', new Text(256), 'Repository Id')
->param('type', '', new WhiteList(['runtime', 'framework']), 'Detector type. Must be one of the following: runtime, framework', enum: new Enum(name: 'VCSDetectionType'))
->param('providerRootDirectory', '', new Text(256, 0), 'Path to Root Directory', true)
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('response')
->inject('dbForPlatform')
->callback($this->action(...));
@@ -103,7 +104,7 @@ class Create extends Action
string $providerRepositoryId,
string $type,
string $providerRootDirectory,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Response $response,
Database $dbForPlatform
) {
@@ -114,7 +115,7 @@ class Create extends Action
}
$providerInstallationId = $installation->getAttribute('providerInstallationId');
$vcs = $vcsForInstallation($installation);
$vcs = $vcsFactory->fromInstallation($installation);
$owner = $vcs->getOwnerName($providerInstallationId);
try {
@@ -8,6 +8,7 @@ use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Platform\Scope\HTTP;
@@ -47,7 +48,7 @@ class Get extends Action
))
->param('installationId', '', new Text(256), 'Installation Id')
->param('providerRepositoryId', '', new Text(256), 'Repository Id')
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('response')
->inject('dbForPlatform')
->callback($this->action(...));
@@ -56,7 +57,7 @@ class Get extends Action
public function action(
string $installationId,
string $providerRepositoryId,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Response $response,
Database $dbForPlatform
) {
@@ -67,7 +68,7 @@ class Get extends Action
}
$providerInstallationId = $installation->getAttribute('providerInstallationId');
$vcs = $vcsForInstallation($installation);
$vcs = $vcsFactory->fromInstallation($installation);
$owner = $vcs->getOwnerName($providerInstallationId);
try {
@@ -8,6 +8,7 @@ use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response;
use Appwrite\Vcs\Factory as VcsFactory;
use Swoole\Coroutine\WaitGroup;
use Utopia\Config\Adapters\Dotenv as ConfigDotenv;
use Utopia\Config\Config;
@@ -96,7 +97,7 @@ class XList extends Action
->param('type', '', new WhiteList(['runtime', 'framework']), 'Detector type. Must be one of the following: runtime, framework', enum: new Enum(name: 'VCSDetectionType'))
->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true)
->param('queries', [], new Queries([new Limit(), new Offset()]), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset', true)
->inject('vcsForInstallation')
->inject('vcsFactory')
->inject('response')
->inject('dbForPlatform')
->callback($this->action(...));
@@ -107,7 +108,7 @@ class XList extends Action
string $type,
string $search,
array $queries,
callable $vcsForInstallation,
VcsFactory $vcsFactory,
Response $response,
Database $dbForPlatform
) {
@@ -122,7 +123,7 @@ class XList extends Action
}
$providerInstallationId = $installation->getAttribute('providerInstallationId');
$vcs = $vcsForInstallation($installation);
$vcs = $vcsFactory->fromInstallation($installation);
$queries = Query::parseQueries($queries);
$limitQuery = current(array_filter($queries, fn ($query) => $query->getMethod() === Query::TYPE_LIMIT));