Add remote docker-compose support with docker host (-H) for sql:sync and rsync
For some background on this topic see https://github.com/drush-ops/drush/issues/5912 and its linked issue.
Unfortunately, too much of the docker details in this PR are bleeding into Drush. The goal is for all of that to be attracted into transports in the consolidation/site-process project. I'm aware that this implies that sql:sync and rsync: may never work as that abstraction isn't enough. This is unfortunate, but necessary for manageable maintenance of Drush project.
Hi @weitzman, I think it would be great to have rsync and sql:sync support for docker compose and kubernetes. There are a lot of docker compose environments out there and installing an SSH container is not always possible and even yes it is a pain. The same for kubernetes.
So try it with a new idea. :)
- we can make extend the TransportInterface to handle transport specific adjustments of command and make it easy to implement own transports. (I found ProcessManager::addTransports which adds transports hard coded. Is there a way right now to register own transports? )
Something like:
SshTransport"InDrushPackage" implements RsyncCommandsAlter, SqlSyncCommandsAlter {
...
public function rsyncTransportArgs(DrushCommands $command) {
$ssh_options = $command->getConfig()->get('ssh.options', '');
$parameters[] = Escape::shellArg($command->sourceEvaluatedPath->fullyQualifiedPathPreservingTrailingSlash());
$parameters[] = Escape::shellArg($command->targetEvaluatedPath->fullyQualifiedPath());
return 'ssh $ssh_options'" . ' ' . implode(' ', array_filter($parameters)';
}
...
Inside rsync:
public function rsync($source, $target, array $extra, $options = ['exclude-paths' => self::REQ, 'include-paths' => self::REQ, 'mode' => 'akz']): void
{
$transport = $this->getConfig()->getTransport()
if (transport instanceof RsyncCommandsAlter) {
$rsync_args = $transport->rsyncTransportArgs($this);
}
}
Or we use some kind of events?
It still looks messy to me, but I'll accept it if @greg-1-anderson agrees with the direction. I pinged him in #drush
Adding own transports is not possible yet. Requested at https://github.com/consolidation/site-process/issues/52