Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platformsh integration #35

Open
wants to merge 3 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Robo/Plugin/Commands/GetDBCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ public function getDB(ConsoleIO $io, array $args) {
return 'Acquia CLI is not installed, please install and configure it: https://docs.acquia.com/acquia-cli/install/';
}
break;
case 'platform':
if ($this->getCliToolStatus('platform')) {
$cmd = "platform db:dump --gzip --file=$dbFolder/site-db.sql.gz -p $remoteSiteName -e $remoteEnv";
}
else {
return 'Platform CLI is not installed, please install and configure it: https://docs.platform.sh/administration/cli.html';
}
break;
case 'pantheon':
default:
if ($this->getCliToolStatus('terminus')) {
Expand Down
26 changes: 26 additions & 0 deletions src/Robo/Plugin/Commands/GetFilesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public function getFiles(ConsoleIO $io, $opts = ['no-download' => FALSE]) {
case 'acquia':
$tasks = $this->getFilesAcquia($io, $tasks, $remoteSiteName, $remoteEnv);
break;
case 'platform':
$tasks = $this->getFilesPlatform($io, $tasks, $remoteSiteName, $remoteEnv);
break;
case 'pantheon':
default:
$tasks = $this->getFilesPantheon($io, $opts, $tasks, $remoteSiteName, $remoteEnv, $origFilesFolder, $destFilesFolder);
Expand Down Expand Up @@ -78,6 +81,7 @@ private function getFilesAcquia(ConsoleIO $io, $tasks, $remoteSiteName, $remoteE
else {
return 'Your Local env doesnt have a valid acquia project structure, your drupal root should be the "docroot" folder.';
}

return $tasks;
}

Expand All @@ -103,4 +107,26 @@ private function getFilesPantheon(ConsoleIO $io, array $opts, $tasks, $remoteSit

return $tasks;
}

/**
* Helper function to get files from PlatformSH.
*/
private function getFilesPlatform(ConsoleIO $io, $tasks, $remoteSiteName, $remoteEnv) {
if (file_exists($this->getLocalEnvRoot() . '/web/sites/default/files')) {
if ($this->getCliToolStatus('platform')) {
$io->say('Syncing files from the ' . $remoteEnv . ' environment...');
$cmd = "platform mount:download /mnt/files {$this->getLocalEnvRoot()}/web/sites/default/files -p $remoteSiteName -e $remoteEnv";
$tasks->addTask($this->taskExec($cmd));
}
else {
return 'Platform CLI is not installed, please install and configure it: https://docs.platform.sh/administration/cli.html';
}
}
else {
return 'Your Local env doesnt have a valid platform project structure, your drupal root should be the "web" folder.';
}

return $tasks;
}

}