processSource
This commit is contained in:
parent
6149f46621
commit
73280fd173
|
@ -95,15 +95,13 @@ class Migrations extends Action
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Document $document
|
* @param string $source
|
||||||
|
* @param array $credentials
|
||||||
* @return Source
|
* @return Source
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected function processSource(Document $document): Source
|
protected function processSource(string $source, array $credentials): Source
|
||||||
{
|
{
|
||||||
$source = $document->getAttribute('source');
|
|
||||||
$credentials = $document->getAttribute('credentials');
|
|
||||||
|
|
||||||
return match ($source) {
|
return match ($source) {
|
||||||
Firebase::getName() => new Firebase(
|
Firebase::getName() => new Firebase(
|
||||||
json_decode($credentials['serviceAccount'], true),
|
json_decode($credentials['serviceAccount'], true),
|
||||||
|
@ -126,7 +124,11 @@ class Migrations extends Action
|
||||||
$credentials['password'],
|
$credentials['password'],
|
||||||
$credentials['port'],
|
$credentials['port'],
|
||||||
),
|
),
|
||||||
Appwrite::getName() => new Appwrite($credentials['projectId'], str_starts_with($credentials['endpoint'], 'http://localhost/v1') ? 'http://appwrite/v1' : $credentials['endpoint'], $credentials['apiKey']),
|
Appwrite::getName() => new Appwrite(
|
||||||
|
$credentials['projectId'],
|
||||||
|
str_starts_with($credentials['endpoint'], 'http://localhost/v1') ? 'http://appwrite/v1' : $credentials['endpoint'],
|
||||||
|
$credentials['apiKey']
|
||||||
|
),
|
||||||
default => throw new \Exception('Invalid source type'),
|
default => throw new \Exception('Invalid source type'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -285,8 +287,19 @@ class Migrations extends Action
|
||||||
|
|
||||||
$log->addTag('type', $migrationDocument->getAttribute('source'));
|
$log->addTag('type', $migrationDocument->getAttribute('source'));
|
||||||
|
|
||||||
//$source = $this->processSource($migrationDocument->getAttribute('source'), $migrationDocument->getAttribute('credentials'));
|
$source = $this->processSource(
|
||||||
$source = $this->processSource($migrationDocument);
|
$migrationDocument->getAttribute('source'),
|
||||||
|
$migrationDocument->getAttribute('credentials')
|
||||||
|
);
|
||||||
|
|
||||||
|
$destination = $this->processDestination(
|
||||||
|
$migrationDocument->getAttribute('destination'),
|
||||||
|
[
|
||||||
|
'projectId' => $projectDocument->getId(),
|
||||||
|
'endpoint' => 'http://appwrite/v1',
|
||||||
|
'apiKey' => $tempAPIKey['secret']
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
$source->report();
|
$source->report();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue