Skip to content
Merged
42 changes: 34 additions & 8 deletions app/config/specs/open-api3-latest-console.json
Original file line number Diff line number Diff line change
Expand Up @@ -12927,10 +12927,22 @@
"description": "Path to function code in the template repo.",
"x-example": "<ROOT_DIRECTORY>"
},
"version": {
"type": {
"type": "string",
"description": "Version (tag) for the repo linked to the function template.",
"x-example": "<VERSION>"
"description": "Type for the reference provided. Can be commit, branch, or tag",
"x-example": "commit",
"enum": [
"commit",
"branch",
"tag"
],
"x-enum-name": null,
"x-enum-keys": []
},
"reference": {
"type": "string",
"description": "Reference value, can be a commit hash, branch name, or release tag",
"x-example": "<REFERENCE>"
},
"activate": {
"type": "boolean",
Expand All @@ -12942,7 +12954,8 @@
"repository",
"owner",
"rootDirectory",
"version"
"type",
"reference"
]
}
}
Expand Down Expand Up @@ -30205,10 +30218,22 @@
"description": "Path to site code in the template repo.",
"x-example": "<ROOT_DIRECTORY>"
},
"version": {
"type": {
"type": "string",
"description": "Version (tag) for the repo linked to the site template.",
"x-example": "<VERSION>"
"description": "Type for the reference provided. Can be commit, branch, or tag",
"x-example": "branch",
"enum": [
"branch",
"commit",
"tag"
],
"x-enum-name": null,
"x-enum-keys": []
},
"reference": {
"type": "string",
"description": "Reference value, can be a commit hash, branch name, or release tag",
"x-example": "<REFERENCE>"
},
"activate": {
"type": "boolean",
Expand All @@ -30220,7 +30245,8 @@
"repository",
"owner",
"rootDirectory",
"version"
"type",
"reference"
]
}
}
Expand Down
42 changes: 34 additions & 8 deletions app/config/specs/open-api3-latest-server.json
Original file line number Diff line number Diff line change
Expand Up @@ -11709,10 +11709,22 @@
"description": "Path to function code in the template repo.",
"x-example": "<ROOT_DIRECTORY>"
},
"version": {
"type": {
"type": "string",
"description": "Version (tag) for the repo linked to the function template.",
"x-example": "<VERSION>"
"description": "Type for the reference provided. Can be commit, branch, or tag",
"x-example": "commit",
"enum": [
"commit",
"branch",
"tag"
],
"x-enum-name": null,
"x-enum-keys": []
},
"reference": {
"type": "string",
"description": "Reference value, can be a commit hash, branch name, or release tag",
"x-example": "<REFERENCE>"
},
"activate": {
"type": "boolean",
Expand All @@ -11724,7 +11736,8 @@
"repository",
"owner",
"rootDirectory",
"version"
"type",
"reference"
]
}
}
Expand Down Expand Up @@ -20912,10 +20925,22 @@
"description": "Path to site code in the template repo.",
"x-example": "<ROOT_DIRECTORY>"
},
"version": {
"type": {
"type": "string",
"description": "Version (tag) for the repo linked to the site template.",
"x-example": "<VERSION>"
"description": "Type for the reference provided. Can be commit, branch, or tag",
"x-example": "branch",
"enum": [
"branch",
"commit",
"tag"
],
"x-enum-name": null,
"x-enum-keys": []
},
"reference": {
"type": "string",
"description": "Reference value, can be a commit hash, branch name, or release tag",
"x-example": "<REFERENCE>"
},
"activate": {
"type": "boolean",
Expand All @@ -20927,7 +20952,8 @@
"repository",
"owner",
"rootDirectory",
"version"
"type",
"reference"
]
}
}
Expand Down
44 changes: 36 additions & 8 deletions app/config/specs/swagger2-latest-console.json
Original file line number Diff line number Diff line change
Expand Up @@ -12925,11 +12925,24 @@
"default": null,
"x-example": "<ROOT_DIRECTORY>"
},
"version": {
"type": {
"type": "string",
"description": "Type for the reference provided. Can be commit, branch, or tag",
"default": null,
"x-example": "commit",
"enum": [
"commit",
"branch",
"tag"
],
"x-enum-name": null,
"x-enum-keys": []
},
"reference": {
"type": "string",
"description": "Version (tag) for the repo linked to the function template.",
"description": "Reference value, can be a commit hash, branch name, or release tag",
"default": null,
"x-example": "<VERSION>"
"x-example": "<REFERENCE>"
},
"activate": {
"type": "boolean",
Expand All @@ -12942,7 +12955,8 @@
"repository",
"owner",
"rootDirectory",
"version"
"type",
"reference"
]
}
}
Expand Down Expand Up @@ -30383,11 +30397,24 @@
"default": null,
"x-example": "<ROOT_DIRECTORY>"
},
"version": {
"type": {
"type": "string",
"description": "Version (tag) for the repo linked to the site template.",
"description": "Type for the reference provided. Can be commit, branch, or tag",
"default": null,
"x-example": "<VERSION>"
"x-example": "branch",
"enum": [
"branch",
"commit",
"tag"
],
"x-enum-name": null,
"x-enum-keys": []
},
"reference": {
"type": "string",
"description": "Reference value, can be a commit hash, branch name, or release tag",
"default": null,
"x-example": "<REFERENCE>"
},
"activate": {
"type": "boolean",
Expand All @@ -30400,7 +30427,8 @@
"repository",
"owner",
"rootDirectory",
"version"
"type",
"reference"
]
}
}
Expand Down
44 changes: 36 additions & 8 deletions app/config/specs/swagger2-latest-server.json
Original file line number Diff line number Diff line change
Expand Up @@ -11732,11 +11732,24 @@
"default": null,
"x-example": "<ROOT_DIRECTORY>"
},
"version": {
"type": {
"type": "string",
"description": "Type for the reference provided. Can be commit, branch, or tag",
"default": null,
"x-example": "commit",
"enum": [
"commit",
"branch",
"tag"
],
"x-enum-name": null,
"x-enum-keys": []
},
"reference": {
"type": "string",
"description": "Version (tag) for the repo linked to the function template.",
"description": "Reference value, can be a commit hash, branch name, or release tag",
"default": null,
"x-example": "<VERSION>"
"x-example": "<REFERENCE>"
},
"activate": {
"type": "boolean",
Expand All @@ -11749,7 +11762,8 @@
"repository",
"owner",
"rootDirectory",
"version"
"type",
"reference"
]
}
}
Expand Down Expand Up @@ -21133,11 +21147,24 @@
"default": null,
"x-example": "<ROOT_DIRECTORY>"
},
"version": {
"type": {
"type": "string",
"description": "Version (tag) for the repo linked to the site template.",
"description": "Type for the reference provided. Can be commit, branch, or tag",
"default": null,
"x-example": "<VERSION>"
"x-example": "branch",
"enum": [
"branch",
"commit",
"tag"
],
"x-enum-name": null,
"x-enum-keys": []
},
"reference": {
"type": "string",
"description": "Reference value, can be a commit hash, branch name, or release tag",
"default": null,
"x-example": "<REFERENCE>"
},
"activate": {
"type": "boolean",
Expand All @@ -21150,7 +21177,8 @@
"repository",
"owner",
"rootDirectory",
"version"
"type",
"reference"
]
}
}
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Appwrite\Utopia\Request\Filters\V18 as RequestV18;
use Appwrite\Utopia\Request\Filters\V19 as RequestV19;
use Appwrite\Utopia\Request\Filters\V20 as RequestV20;
use Appwrite\Utopia\Request\Filters\V21 as RequestV21;
use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Filters\V16 as ResponseV16;
use Appwrite\Utopia\Response\Filters\V17 as ResponseV17;
Expand Down Expand Up @@ -906,6 +907,9 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw
$dbForProject = $getProjectDB($project);
$request->addFilter(new RequestV20($dbForProject, $route->getPathValues($request)));
}
if (version_compare($requestFormat, '1.9.0', '<')) {
$request->addFilter(new RequestV21());
}
}

$domain = $request->getHostname();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Utopia\Swoole\Request;
use Utopia\Validator\Boolean;
use Utopia\Validator\Text;
use Utopia\Validator\WhiteList;
use Utopia\VCS\Adapter\Git\GitHub;

class Create extends Base
Expand Down Expand Up @@ -65,7 +66,8 @@ public function __construct()
->param('repository', '', new Text(128, 0), 'Repository name of the template.')
->param('owner', '', new Text(128, 0), 'The name of the owner of the template.')
->param('rootDirectory', '', new Text(128, 0), 'Path to function code in the template repo.')
->param('version', '', new Text(128, 0), 'Version (tag) for the repo linked to the function template.')
->param('type', '', new WhiteList(['commit', 'branch', 'tag']), 'Type for the reference provided. Can be commit, branch, or tag')
->param('reference', '', new Text(128, 0), 'Reference value, can be a commit hash, branch name, or release tag')
->param('activate', false, new Boolean(), 'Automatically activate the deployment when it is finished building.', true)
Comment thread
atharvadeosthale marked this conversation as resolved.
->inject('request')
->inject('response')
Expand All @@ -83,7 +85,8 @@ public function action(
string $repository,
string $owner,
string $rootDirectory,
string $version,
string $type,
string $reference,
bool $activate,
Request $request,
Response $response,
Expand All @@ -100,11 +103,16 @@ public function action(
throw new Exception(Exception::FUNCTION_NOT_FOUND);
}

$branchUrl = "https://github.com/$owner/$repository/blob/$reference";

$repositoryUrl = "https://github.com/$owner/$repository";

$template = new Document([
'repositoryName' => $repository,
'ownerName' => $owner,
'rootDirectory' => $rootDirectory,
'version' => $version
'referenceType' => $type,
'referenceValue' => $reference,
]);

if (!empty($function->getAttribute('providerRepositoryId'))) {
Expand Down Expand Up @@ -146,7 +154,12 @@ function: $function,
'resourceType' => 'functions',
'entrypoint' => $function->getAttribute('entrypoint', ''),
'buildCommands' => $function->getAttribute('commands', ''),
'type' => 'manual',
'providerRepositoryName' => $repository,
'providerRepositoryOwner' => $owner,
'providerRepositoryUrl' => $repositoryUrl,
'providerBranchUrl' => $branchUrl,
'providerBranch' => $type == GitHub::CLONE_TYPE_BRANCH ? $reference : '',
'type' => 'vcs',
'activate' => $activate,
]));

Expand Down
Loading
Loading