mirror of
https://github.com/appwrite/appwrite
synced 2026-05-22 00:18:25 +00:00
credentials
This commit is contained in:
parent
f12a578efe
commit
41beb8af9c
1 changed files with 14 additions and 10 deletions
|
|
@ -126,7 +126,7 @@ class Migrations extends Action
|
|||
),
|
||||
SourceAppwrite::getName() => new SourceAppwrite(
|
||||
$credentials['projectId'],
|
||||
str_starts_with($credentials['endpoint'], 'http://localhost/v1') ? 'http://appwrite/v1' : $credentials['endpoint'],
|
||||
$credentials['endpoint'],
|
||||
$credentials['apiKey']
|
||||
),
|
||||
default => throw new \Exception('Invalid source type'),
|
||||
|
|
@ -136,14 +136,15 @@ class Migrations extends Action
|
|||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function processDestination(Document $migration, array $credentials): Destination
|
||||
protected function processDestination(Document $migration): Destination
|
||||
{
|
||||
$destination = $migration->getAttribute('destination');
|
||||
$credentials = $migration->getAttribute('credentials');
|
||||
|
||||
return match ($destination) {
|
||||
DestinationAppwrite::getName() => new DestinationAppwrite(
|
||||
$credentials['projectId'],
|
||||
str_starts_with($credentials['endpoint'], 'http://localhost/v1') ? 'http://appwrite/v1' : $credentials['endpoint'],
|
||||
$credentials['endpoint'],
|
||||
$credentials['apiKey'],
|
||||
$this->dbForProject,
|
||||
Config::getParam('collections', [])['databases']['collections'],
|
||||
|
|
@ -277,16 +278,19 @@ class Migrations extends Action
|
|||
|
||||
$log->addTag('type', $migration->getAttribute('source'));
|
||||
|
||||
$source = $this->processSource($migration);
|
||||
|
||||
$destination = $this->processDestination(
|
||||
$migration,
|
||||
[
|
||||
if (
|
||||
$migration->getAttribute('source') === SourceAppwrite::getName() ||
|
||||
$migration->getAttribute('destination') === DestinationAppwrite::getName()
|
||||
) {
|
||||
$migration->setAttribute('credentials', [
|
||||
'projectId' => $projectDocument->getId(),
|
||||
'endpoint' => 'http://appwrite/v1',
|
||||
'apiKey' => $tempAPIKey['secret'],
|
||||
]
|
||||
);
|
||||
]);
|
||||
}
|
||||
|
||||
$source = $this->processSource($migration);
|
||||
$destination = $this->processDestination($migration);
|
||||
|
||||
$source->report();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue