processDestination
This commit is contained in:
parent
bdb7350994
commit
6149f46621
1 changed files with 21 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue