Improve response models for console
This commit is contained in:
parent
a174562c4e
commit
1b4036078b
2
.gitmodules
vendored
2
.gitmodules
vendored
|
@ -1,4 +1,4 @@
|
|||
[submodule "app/console"]
|
||||
path = app/console
|
||||
url = https://github.com/appwrite/console
|
||||
branch = feat-git-integration
|
||||
branch = feat-g4
|
||||
|
|
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
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
Subproject commit 86b4fab774af168f032b38d46e610f4a02294196
|
||||
Subproject commit 4129413f128d356464f935ca466d9c147f72a0a0
|
|
@ -47,7 +47,7 @@ use Utopia\Database\Exception\Duplicate as DuplicateException;
|
|||
|
||||
include_once __DIR__ . '/../shared/api.php';
|
||||
|
||||
$redeployVcsLogic = function (Document $function, Document $project, Document $installation, Document $template, Database $dbForProject) {
|
||||
$redeployVcsLogic = function (Document $function, Document $project, Document $installation, Database $dbForProject, Document $template) {
|
||||
$deploymentId = ID::unique();
|
||||
$entrypoint = $function->getAttribute('entrypoint', '');
|
||||
$deployment = $dbForProject->createDocument('deployments', new Document([
|
||||
|
@ -213,7 +213,7 @@ App::post('/v1/functions')
|
|||
|
||||
// Redeploy vcs logic
|
||||
if (!empty($vcsRepositoryId)) {
|
||||
$redeployVcsLogic($function, $project, $installation, $template, $dbForProject);
|
||||
$redeployVcsLogic($function, $project, $installation, $dbForProject, $template);
|
||||
}
|
||||
|
||||
$functionsDomain = App::getEnv('_APP_DOMAIN_FUNCTIONS', 'disabled');
|
||||
|
@ -736,7 +736,7 @@ App::put('/v1/functions/:functionId')
|
|||
|
||||
// Redeploy logic
|
||||
if (!$isConnected && !empty($vcsRepositoryId)) {
|
||||
$redeployVcsLogic($function, $project, $installation, $dbForProject);
|
||||
$redeployVcsLogic($function, $project, $installation, $dbForProject, new Document());
|
||||
}
|
||||
|
||||
$schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId'));
|
||||
|
|
|
@ -249,9 +249,11 @@ App::get('/v1/vcs/github/installations/:installationId/repositories')
|
|||
// Limit the maximum results to 5
|
||||
$repos = \array_slice($repos, 0, 5);
|
||||
|
||||
$repos = \array_map(function ($repo) {
|
||||
$repos = \array_map(function ($repo) use ($installation) {
|
||||
$repo['id'] = \strval($repo['id']);
|
||||
$repo['pushedAt'] = $repo['pushed_at'];
|
||||
$repo['provider'] = $installation->getAttribute('provider', '');
|
||||
$repo['organization'] = $installation->getAttribute('organization', '');
|
||||
return new Document($repo);
|
||||
}, $repos);
|
||||
|
||||
|
@ -374,6 +376,8 @@ App::get('/v1/vcs/github/installations/:installationId/repositories/:repositoryI
|
|||
|
||||
$repository['id'] = \strval($repository['id']);
|
||||
$repository['pushedAt'] = $repository['pushed_at'];
|
||||
$repository['organization'] = $installation->getAttribute('organization', '');
|
||||
$repository['provider'] = $installation->getAttribute('provider', '');
|
||||
|
||||
$response->dynamic(new Document($repository), Response::MODEL_REPOSITORY);
|
||||
});
|
||||
|
@ -470,17 +474,20 @@ $createGitDeployments = function (GitHub $github, string $installationId, string
|
|||
$owner = $github->getOwnerName($installationId);
|
||||
$repositoryName = $github->getRepositoryName($repositoryId);
|
||||
|
||||
$comment = new Comment();
|
||||
// TODO: Add all builds
|
||||
$comment->addBuild($project, $function, 'waiting', $deploymentId);
|
||||
|
||||
if (empty($latestCommentId)) {
|
||||
$comment = new Comment();
|
||||
$comment->addBuild($project, $function, 'waiting', $deploymentId);
|
||||
|
||||
$pullRequest = $github->getBranchPullRequest($owner, $repositoryName, $branchName);
|
||||
if (!empty($pullRequest)) {
|
||||
$pullRequestNumber = \strval($pullRequest['number']);
|
||||
$latestCommentId = $github->createComment($owner, $repositoryName, $pullRequestNumber, $comment->generateComment());
|
||||
}
|
||||
} else {
|
||||
$comment = new Comment();
|
||||
$comment->parseComment($github->getComment($owner, $repositoryName, $latestCommentId));
|
||||
$comment->addBuild($project, $function, 'waiting', $deploymentId);
|
||||
|
||||
$latestCommentId = $github->updateComment($owner, $repositoryName, $latestCommentId, $comment->generateComment());
|
||||
}
|
||||
|
||||
|
@ -508,8 +515,7 @@ $createGitDeployments = function (GitHub $github, string $installationId, string
|
|||
'activate' => $activate,
|
||||
]));
|
||||
|
||||
// TODO: Figure out port
|
||||
$targetUrl = $request->getProtocol() . '://' . $request->getHostname() . ":3000/console/project-$projectId/functions/function-$functionId";
|
||||
$targetUrl = $request->getProtocol() . '://' . $request->getHostname() . "/console/project-$projectId/functions/function-$functionId";
|
||||
|
||||
if (!empty($SHA) && $function->getAttribute('vcsSilentMode', false) === false) {
|
||||
$functionName = $function->getAttribute('name');
|
||||
|
|
|
@ -936,7 +936,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons
|
|||
if ($project->isEmpty()) {
|
||||
$user = new Document(['$id' => ID::custom(''), '$collection' => 'users']);
|
||||
} else {
|
||||
if($project->getId() === 'console') {
|
||||
if ($project->getId() === 'console') {
|
||||
$user = $dbForConsole->getDocument('users', Auth::$unique);
|
||||
} else {
|
||||
$user = $dbForProject->getDocument('users', Auth::$unique);
|
||||
|
|
|
@ -22,6 +22,19 @@ class Repository extends Model
|
|||
'default' => '',
|
||||
'example' => 'appwrite',
|
||||
])
|
||||
->addRule('organization', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Installation organization.',
|
||||
'default' => [],
|
||||
'example' => 'appwrite',
|
||||
'array' => false,
|
||||
])
|
||||
->addRule('provider', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Repository Installation Pame.',
|
||||
'default' => '',
|
||||
'example' => 'github',
|
||||
])
|
||||
->addRule('private', [
|
||||
'type' => self::TYPE_BOOLEAN,
|
||||
'description' => 'Is repository private?',
|
||||
|
|
Loading…
Reference in a new issue