mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
refactor: inline the buildPath device lookup
This commit is contained in:
2 files changed
+1
-51
No files matched your search
@@ -184,7 +184,7 @@ readonly class Deployments
|
||||
|
||||
$queued = $this->dbForProject->updateDocuments('deployments', new Document([
|
||||
'status' => 'waiting',
|
||||
'buildPath' => $this->devicePath($deployment),
|
||||
'buildPath' => $this->deviceForBuilds->getPath($deployment->getId() . '/' . static::artifact()),
|
||||
]), [
|
||||
Query::equal('$id', [$deployment->getId()]),
|
||||
Query::notEqual('status', 'canceled'),
|
||||
@@ -477,17 +477,6 @@ readonly class Deployments
|
||||
return APP_STORAGE_BUILDS . "/app-{$projectId}/{$deploymentId}";
|
||||
}
|
||||
|
||||
/**
|
||||
* The deployment's buildPath: where the artifact lives on the builds
|
||||
* device, which is what the executor, the download endpoint and the
|
||||
* deletes worker read. Matches buildPath() on the local device; a remote
|
||||
* device (S3 and friends) keys it under its own root, bucket included.
|
||||
*/
|
||||
public function devicePath(Document $deployment): string
|
||||
{
|
||||
return $this->deviceForBuilds->getPath($deployment->getId() . '/' . static::artifact());
|
||||
}
|
||||
|
||||
/**
|
||||
* The build output path on the builds volume. On the local device this is
|
||||
* also the deployment's buildPath; on a remote device (S3 and friends) the
|
||||
|
||||
@@ -6,14 +6,9 @@ namespace Tests\Unit\Deployment;
|
||||
|
||||
use Appwrite\Deployment\Deployments;
|
||||
use Appwrite\Extend\Exception;
|
||||
use OpenRuntimes\Orchestrator\Jobs;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Storage\Device;
|
||||
use Utopia\Storage\Device\Local;
|
||||
use Utopia\Storage\Device\S3;
|
||||
|
||||
final class DeploymentsTest extends TestCase
|
||||
{
|
||||
@@ -133,40 +128,6 @@ final class DeploymentsTest extends TestCase
|
||||
$this->assertSame(['users.read'], Deployments::scopes($site));
|
||||
}
|
||||
|
||||
private function deployments(Device $deviceForBuilds): Deployments
|
||||
{
|
||||
return new Deployments(
|
||||
new Jobs(),
|
||||
$this->createStub(Database::class),
|
||||
new Document(['$id' => 'project1']),
|
||||
['apiHostname' => 'localhost'],
|
||||
$deviceForBuilds,
|
||||
);
|
||||
}
|
||||
|
||||
public function testDevicePathOnLocalDeviceIsTheVolumePath(): void
|
||||
{
|
||||
$deployments = $this->deployments(new Local(APP_STORAGE_BUILDS . '/app-project1'));
|
||||
|
||||
$this->assertSame(
|
||||
Deployments::buildPath('project1', 'deployment1'),
|
||||
$deployments->devicePath(new Document(['$id' => 'deployment1']))
|
||||
);
|
||||
}
|
||||
|
||||
public function testDevicePathOnRemoteDeviceIsKeyedUnderTheDeviceRoot(): void
|
||||
{
|
||||
// An S3-compatible endpoint folds the bucket into the device root (see
|
||||
// getDevice()), so the artifact key is not the volume path.
|
||||
$device = new S3('appwrite' . APP_STORAGE_BUILDS . '/app-project1', 'key', 'secret', 'http://minio:9000', 'us-east-1');
|
||||
$deployments = $this->deployments($device);
|
||||
|
||||
$path = $deployments->devicePath(new Document(['$id' => 'deployment1']));
|
||||
|
||||
$this->assertSame('appwrite' . APP_STORAGE_BUILDS . '/app-project1/deployment1/' . Deployments::artifact(), $path);
|
||||
$this->assertNotSame(Deployments::buildPath('project1', 'deployment1'), $path);
|
||||
}
|
||||
|
||||
private function buildPayload(array $vars): array
|
||||
{
|
||||
// Presigned-URL and ephemeral-key signing both run before the
|
||||
|
||||
Reference in new issue
Block a user