1
0
Fork 0
mirror of synced 2024-07-03 13:41:01 +12:00

processDestination

This commit is contained in:
fogelito 2024-05-28 19:59:54 +03:00
parent bdb7350994
commit 6149f46621

View file

@ -6,6 +6,7 @@ use Appwrite\Event\Event;
use Appwrite\Messaging\Adapter\Realtime;
use Appwrite\Permission;
use Appwrite\Role;
use Appwrite\Utopia\Migration\Destinations\Backup;
use Exception;
use Utopia\CLI\Console;
use Utopia\Database\Database;
@ -17,7 +18,8 @@ use Utopia\Database\Exception\Structure;
use Utopia\Database\Helpers\ID;
use Utopia\Logger\Log;
use Utopia\Logger\Log\Breadcrumb;
use Utopia\Migration\Destinations\Appwrite as DestinationsAppwrite;
use Utopia\Migration\Destination;
use Utopia\Migration\Destinations\Appwrite as DestinationAppwrite;
use Utopia\Migration\Exception as MigrationException;
use Utopia\Migration\Source;
use Utopia\Migration\Sources\Appwrite;
@ -129,6 +131,24 @@ class Migrations extends Action
};
}
/**
* @param string $destination
* @param array $credentials
* @return Destination
* @throws Exception
*/
protected function processDestination(string $destination, array $credentials): Destination
{
return match ($destination) {
DestinationAppwrite::getName() => new DestinationAppwrite(
$credentials['projectId'],
str_starts_with($credentials['endpoint'], 'http://localhost/v1') ? 'http://appwrite/v1' : $credentials['endpoint'],
$credentials['apiKey']
),
default => throw new \Exception('Invalid destination type'),
};
}
/**
* @throws Authorization
* @throws Structure