mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +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(
|
SourceAppwrite::getName() => new SourceAppwrite(
|
||||||
$credentials['projectId'],
|
$credentials['projectId'],
|
||||||
str_starts_with($credentials['endpoint'], 'http://localhost/v1') ? 'http://appwrite/v1' : $credentials['endpoint'],
|
$credentials['endpoint'],
|
||||||
$credentials['apiKey']
|
$credentials['apiKey']
|
||||||
),
|
),
|
||||||
default => throw new \Exception('Invalid source type'),
|
default => throw new \Exception('Invalid source type'),
|
||||||
|
|
@ -136,14 +136,15 @@ class Migrations extends Action
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected function processDestination(Document $migration, array $credentials): Destination
|
protected function processDestination(Document $migration): Destination
|
||||||
{
|
{
|
||||||
$destination = $migration->getAttribute('destination');
|
$destination = $migration->getAttribute('destination');
|
||||||
|
$credentials = $migration->getAttribute('credentials');
|
||||||
|
|
||||||
return match ($destination) {
|
return match ($destination) {
|
||||||
DestinationAppwrite::getName() => new DestinationAppwrite(
|
DestinationAppwrite::getName() => new DestinationAppwrite(
|
||||||
$credentials['projectId'],
|
$credentials['projectId'],
|
||||||
str_starts_with($credentials['endpoint'], 'http://localhost/v1') ? 'http://appwrite/v1' : $credentials['endpoint'],
|
$credentials['endpoint'],
|
||||||
$credentials['apiKey'],
|
$credentials['apiKey'],
|
||||||
$this->dbForProject,
|
$this->dbForProject,
|
||||||
Config::getParam('collections', [])['databases']['collections'],
|
Config::getParam('collections', [])['databases']['collections'],
|
||||||
|
|
@ -277,16 +278,19 @@ class Migrations extends Action
|
||||||
|
|
||||||
$log->addTag('type', $migration->getAttribute('source'));
|
$log->addTag('type', $migration->getAttribute('source'));
|
||||||
|
|
||||||
$source = $this->processSource($migration);
|
if (
|
||||||
|
$migration->getAttribute('source') === SourceAppwrite::getName() ||
|
||||||
$destination = $this->processDestination(
|
$migration->getAttribute('destination') === DestinationAppwrite::getName()
|
||||||
$migration,
|
) {
|
||||||
[
|
$migration->setAttribute('credentials', [
|
||||||
'projectId' => $projectDocument->getId(),
|
'projectId' => $projectDocument->getId(),
|
||||||
'endpoint' => 'http://appwrite/v1',
|
'endpoint' => 'http://appwrite/v1',
|
||||||
'apiKey' => $tempAPIKey['secret'],
|
'apiKey' => $tempAPIKey['secret'],
|
||||||
]
|
]);
|
||||||
);
|
}
|
||||||
|
|
||||||
|
$source = $this->processSource($migration);
|
||||||
|
$destination = $this->processDestination($migration);
|
||||||
|
|
||||||
$source->report();
|
$source->report();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue