Fix variables not being correctly used
This commit is contained in:
parent
c566f1e7c9
commit
15fbe86124
2 changed files with 20 additions and 4 deletions
|
@ -908,11 +908,17 @@ App::post('/v1/functions/:functionId/executions')
|
||||||
return $response->dynamic($execution, Response::MODEL_EXECUTION);
|
return $response->dynamic($execution, Response::MODEL_EXECUTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$vars = [];
|
||||||
|
|
||||||
$variables = $dbForProject->find('variables', [
|
$variables = $dbForProject->find('variables', [
|
||||||
new Query('functionInternalId', Query::TYPE_EQUAL, [$function->getInternalId()]),
|
new Query('functionInternalId', Query::TYPE_EQUAL, [$function->getInternalId()]),
|
||||||
], APP_LIMIT_COUNT);
|
], APP_LIMIT_COUNT);
|
||||||
|
|
||||||
$vars = \array_merge($variables, [
|
foreach ($variables as $variable) {
|
||||||
|
$vars[$variable['key']] = $variable['value'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$vars = \array_merge($vars, [
|
||||||
'APPWRITE_FUNCTION_ID' => $function->getId(),
|
'APPWRITE_FUNCTION_ID' => $function->getId(),
|
||||||
'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''),
|
'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''),
|
||||||
'APPWRITE_FUNCTION_DEPLOYMENT' => $deployment->getId(),
|
'APPWRITE_FUNCTION_DEPLOYMENT' => $deployment->getId(),
|
||||||
|
|
|
@ -13,6 +13,7 @@ use Utopia\CLI\Console;
|
||||||
use Utopia\Config\Config;
|
use Utopia\Config\Config;
|
||||||
use Utopia\Database\Database;
|
use Utopia\Database\Database;
|
||||||
use Utopia\Database\Document;
|
use Utopia\Database\Document;
|
||||||
|
use Utopia\Database\Query;
|
||||||
use Utopia\Database\Validator\Authorization;
|
use Utopia\Database\Validator\Authorization;
|
||||||
|
|
||||||
require_once __DIR__ . '/../init.php';
|
require_once __DIR__ . '/../init.php';
|
||||||
|
@ -257,8 +258,18 @@ class FunctionsV1 extends Worker
|
||||||
$execution->setAttribute('status', 'processing');
|
$execution->setAttribute('status', 'processing');
|
||||||
$execution = $dbForProject->updateDocument('executions', $executionId, $execution);
|
$execution = $dbForProject->updateDocument('executions', $executionId, $execution);
|
||||||
|
|
||||||
|
$vars = [];
|
||||||
|
|
||||||
|
$variables = $dbForProject->find('variables', [
|
||||||
|
new Query('functionInternalId', Query::TYPE_EQUAL, [$function->getInternalId()]),
|
||||||
|
], APP_LIMIT_COUNT);
|
||||||
|
|
||||||
|
foreach ($variables as $variable) {
|
||||||
|
$vars[$variable['key']] = $variable['value'];
|
||||||
|
}
|
||||||
|
|
||||||
/** Collect environment variables */
|
/** Collect environment variables */
|
||||||
$vars = [
|
$vars = \array_merge($vars, [
|
||||||
'APPWRITE_FUNCTION_ID' => $functionId,
|
'APPWRITE_FUNCTION_ID' => $functionId,
|
||||||
'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''),
|
'APPWRITE_FUNCTION_NAME' => $function->getAttribute('name', ''),
|
||||||
'APPWRITE_FUNCTION_DEPLOYMENT' => $deploymentId,
|
'APPWRITE_FUNCTION_DEPLOYMENT' => $deploymentId,
|
||||||
|
@ -271,8 +282,7 @@ class FunctionsV1 extends Worker
|
||||||
'APPWRITE_FUNCTION_PROJECT_ID' => $project->getId(),
|
'APPWRITE_FUNCTION_PROJECT_ID' => $project->getId(),
|
||||||
'APPWRITE_FUNCTION_USER_ID' => $user->getId(),
|
'APPWRITE_FUNCTION_USER_ID' => $user->getId(),
|
||||||
'APPWRITE_FUNCTION_JWT' => $jwt,
|
'APPWRITE_FUNCTION_JWT' => $jwt,
|
||||||
];
|
]);
|
||||||
$vars = \array_merge($function->getAttribute('vars', []), $vars);
|
|
||||||
|
|
||||||
/** Execute function */
|
/** Execute function */
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue