credentials

This commit is contained in:
fogelito 2024-08-08 15:43:11 +03:00
parent 41beb8af9c
commit d29740f0d7
2 changed files with 26 additions and 23 deletions

12
composer.lock generated
View file

@ -1721,16 +1721,16 @@
},
{
"name": "utopia-php/database",
"version": "0.50.2",
"version": "0.50.3",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/database.git",
"reference": "c712d1f6c8ec37886a7a1ad4d60a8cd75dec00aa"
"reference": "4287e6625c7273411c7322abd151c4285ee7b50f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/c712d1f6c8ec37886a7a1ad4d60a8cd75dec00aa",
"reference": "c712d1f6c8ec37886a7a1ad4d60a8cd75dec00aa",
"url": "https://api.github.com/repos/utopia-php/database/zipball/4287e6625c7273411c7322abd151c4285ee7b50f",
"reference": "4287e6625c7273411c7322abd151c4285ee7b50f",
"shasum": ""
},
"require": {
@ -1771,9 +1771,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/0.50.2"
"source": "https://github.com/utopia-php/database/tree/0.50.3"
},
"time": "2024-07-31T10:12:19+00:00"
"time": "2024-08-08T01:40:54+00:00"
},
{
"name": "utopia-php/domains",

View file

@ -38,6 +38,8 @@ class Migrations extends Action
protected Document $project;
protected array $credentials = [];
public static function getName(): string
{
return 'migrations';
@ -125,9 +127,9 @@ class Migrations extends Action
$credentials['port'],
),
SourceAppwrite::getName() => new SourceAppwrite(
$credentials['projectId'],
$credentials['endpoint'],
$credentials['apiKey']
$this->credentials['projectId'],
$this->credentials['endpoint'],
$this->credentials['apiKey']
),
default => throw new \Exception('Invalid source type'),
};
@ -139,13 +141,12 @@ class Migrations extends Action
protected function processDestination(Document $migration): Destination
{
$destination = $migration->getAttribute('destination');
$credentials = $migration->getAttribute('credentials');
return match ($destination) {
DestinationAppwrite::getName() => new DestinationAppwrite(
$credentials['projectId'],
$credentials['endpoint'],
$credentials['apiKey'],
$this->credentials['projectId'],
$this->credentials['endpoint'],
$this->credentials['apiKey'],
$this->dbForProject,
Config::getParam('collections', [])['databases']['collections'],
),
@ -278,16 +279,18 @@ class Migrations extends Action
$log->addTag('type', $migration->getAttribute('source'));
if (
$migration->getAttribute('source') === SourceAppwrite::getName() ||
$migration->getAttribute('destination') === DestinationAppwrite::getName()
) {
$migration->setAttribute('credentials', [
'projectId' => $projectDocument->getId(),
'endpoint' => 'http://appwrite/v1',
'apiKey' => $tempAPIKey['secret'],
]);
}
// if (
// $migration->getAttribute('source') === SourceAppwrite::getName() ||
// $migration->getAttribute('destination') === DestinationAppwrite::getName()
// ) {
// $migration->setAttribute('credentials', );
// }
$this->credentials = [
'projectId' => $projectDocument->getId(),
'endpoint' => 'http://appwrite/v1',
'apiKey' => $tempAPIKey['secret'],
];
$source = $this->processSource($migration);
$destination = $this->processDestination($migration);