1
0
Fork 0
mirror of synced 2024-06-30 04:00:34 +12:00

PR review changes

This commit is contained in:
Matej Bačo 2023-07-24 15:12:36 +02:00
parent 8655d71a67
commit 743c214a66
8 changed files with 30 additions and 62 deletions

View file

@ -63,9 +63,9 @@ return [
],
[
'name' => '_APP_DOMAIN_FUNCTIONS',
'description' => 'A domain to use for function preview URLs. Setting to "disabled" turns off function preview URLs.',
'description' => 'A domain to use for function preview URLs. Setting to empty turns off function preview URLs.',
'introduction' => '',
'default' => 'disabled',
'default' => '',
'required' => false,
'question' => '',
'filter' => ''

View file

@ -225,8 +225,8 @@ App::post('/v1/functions')
$redeployVcsLogic($request, $function, $project, $installation, $dbForProject, $template);
}
$functionsDomain = App::getEnv('_APP_DOMAIN_FUNCTIONS', 'disabled');
if ($functionsDomain !== 'disabled') {
$functionsDomain = App::getEnv('_APP_DOMAIN_FUNCTIONS', '');
if (!empty($functionsDomain)) {
$ruleId = ID::unique();
$routeSubdomain = ID::unique();
$domain = "{$routeSubdomain}.{$functionsDomain}";
@ -1814,11 +1814,10 @@ App::get('/v1/functions/:functionId/variables/:variableId')
throw new Exception(Exception::FUNCTION_NOT_FOUND);
}
$variable = $dbForProject->findOne('variables', [
Query::equal('$id', [$variableId]),
Query::equal('resourceInternalId', [$function->getInternalId()]),
Query::equal('resourceType', ['function']),
]);
$variable = $dbForProject->getDocument('variables', $variableId);
if ($variable === false || $variable->isEmpty() || $variable->getAttribute('resourceInternalId') !== $function->getInternalId() || $variable->getAttribute('resourceType') !== 'function') {
throw new Exception(Exception::VARIABLE_NOT_FOUND);
}
if ($variable === false || $variable->isEmpty()) {
throw new Exception(Exception::VARIABLE_NOT_FOUND);
@ -1856,11 +1855,10 @@ App::put('/v1/functions/:functionId/variables/:variableId')
throw new Exception(Exception::FUNCTION_NOT_FOUND);
}
$variable = $dbForProject->findOne('variables', [
Query::equal('$id', [$variableId]),
Query::equal('resourceInternalId', [$function->getInternalId()]),
Query::equal('resourceType', ['function']),
]);
$variable = $dbForProject->getDocument('variables', $variableId);
if ($variable === false || $variable->isEmpty() || $variable->getAttribute('resourceInternalId') !== $function->getInternalId() || $variable->getAttribute('resourceType') !== 'function') {
throw new Exception(Exception::VARIABLE_NOT_FOUND);
}
if ($variable === false || $variable->isEmpty()) {
throw new Exception(Exception::VARIABLE_NOT_FOUND);
@ -1916,11 +1914,10 @@ App::delete('/v1/functions/:functionId/variables/:variableId')
throw new Exception(Exception::FUNCTION_NOT_FOUND);
}
$variable = $dbForProject->findOne('variables', [
Query::equal('$id', [$variableId]),
Query::equal('resourceInternalId', [$function->getInternalId()]),
Query::equal('resourceType', ['function']),
]);
$variable = $dbForProject->getDocument('variables', $variableId);
if ($variable === false || $variable->isEmpty() || $variable->getAttribute('resourceInternalId') !== $function->getInternalId() || $variable->getAttribute('resourceType') !== 'function') {
throw new Exception(Exception::VARIABLE_NOT_FOUND);
}
if ($variable === false || $variable->isEmpty()) {
throw new Exception(Exception::VARIABLE_NOT_FOUND);

View file

@ -216,14 +216,11 @@ App::get('/v1/project/variables/:variableId')
->label('sdk.response.model', Response::MODEL_VARIABLE)
->param('variableId', '', new UID(), 'Variable unique ID.', false)
->inject('response')
->inject('project')
->inject('dbForProject')
->action(function (string $variableId, Response $response, Database $dbForProject) {
$variable = $dbForProject->findOne('variables', [
Query::equal('$id', [$variableId]),
Query::equal('resourceType', ['project']),
]);
if ($variable === false || $variable->isEmpty()) {
->action(function (string $variableId, Response $response, Document $project, Database $dbForProject) {
$variable = $dbForProject->getDocument('variables', $variableId);
if ($variable === false || $variable->isEmpty() || $variable->getAttribute('resourceType') !== 'project') {
throw new Exception(Exception::VARIABLE_NOT_FOUND);
}
@ -248,12 +245,8 @@ App::put('/v1/project/variables/:variableId')
->inject('response')
->inject('dbForProject')
->action(function (string $variableId, string $key, ?string $value, Document $project, Response $response, Database $dbForProject) {
$variable = $dbForProject->findOne('variables', [
Query::equal('$id', [$variableId]),
Query::equal('resourceType', ['project']),
]);
if ($variable === false || $variable->isEmpty()) {
$variable = $dbForProject->getDocument('variables', $variableId);
if ($variable === false || $variable->isEmpty() || $variable->getAttribute('resourceType') !== 'project') {
throw new Exception(Exception::VARIABLE_NOT_FOUND);
}
@ -296,12 +289,8 @@ App::delete('/v1/project/variables/:variableId')
->inject('response')
->inject('dbForProject')
->action(function (string $variableId, Document $project, Response $response, Database $dbForProject) {
$variable = $dbForProject->findOne('variables', [
Query::equal('$id', [$variableId]),
Query::equal('resourceType', ['project']),
]);
if ($variable === false || $variable->isEmpty()) {
$variable = $dbForProject->getDocument('variables', $variableId);
if ($variable === false || $variable->isEmpty() || $variable->getAttribute('resourceType') !== 'project') {
throw new Exception(Exception::VARIABLE_NOT_FOUND);
}

View file

@ -94,8 +94,8 @@ App::post('/v1/proxy/rules')
]);
$status = 'created';
$functionsDomain = App::getEnv('_APP_DOMAIN_FUNCTIONS', 'disabled');
if ($functionsDomain !== 'disabled' && \str_ends_with($domain->get(), $functionsDomain)) {
$functionsDomain = App::getEnv('_APP_DOMAIN_FUNCTIONS');
if (!empty($functionsDomain) && \str_ends_with($domain->get(), $functionsDomain)) {
$status = 'verified';
}

View file

@ -742,24 +742,6 @@ services:
- OPR_EXECUTOR_LOGGING_PROVIDER=$_APP_LOGGING_PROVIDER
- OPR_EXECUTOR_LOGGING_CONFIG=$_APP_LOGGING_CONFIG
# openruntimes-proxy:
# container_name: openruntimes-proxy
# hostname: proxy
# <<: *x-logging
# image: meldiron/proxy:0.3.0
# networks:
# - appwrite
# environment:
# - OPR_PROXY_ALGORITHM=random
# - OPR_PROXY_EXECUTORS=exc1,exc2
# - OPR_PROXY_HEALTHCHECK=enabled
# - OPR_PROXY_HEALTHCHECK_INTERVAL=10000
# - OPR_PROXY_SECRET=$_APP_EXECUTOR_SECRET
# - OPR_PROXY_EXECUTOR_SECRET=$_APP_EXECUTOR_SECRET
# - OPR_PROXY_ENV=development
# - OPR_PROXY_LOGGING_PROVIDER=$_APP_LOGGING_PROVIDER
# - OPR_PROXY_LOGGING_CONFIG=$_APP_LOGGING_CONFIG
mariadb:
image: mariadb:10.7 # fix issues when upgrading using: mysql_upgrade -u root -p
container_name: appwrite-mariadb

View file

@ -1 +1 @@
Create a new function variable. These variables can be accessed within function in the `env` object under the request variable.
Create a new function variable. These variables can be accessed within function as environment variable.

View file

@ -1 +1 @@
Create a new project variable. These variables can be accessed by every function.
Create a new project variable.

View file

@ -12,9 +12,9 @@ class Branch extends Model
$this
->addRule('name', [
'type' => self::TYPE_STRING,
'description' => 'Repository Name.',
'description' => 'Branch Name.',
'default' => '',
'example' => 'appwrite',
'example' => 'main',
]);
}