Skip to content

Commit 7b2fd7d

Browse files
authored
Fix #1910. Add support for site aliases that point into a Docker container (#3835)
* Add support for site aliases that point into a Docker container * Update Composer for site-process and site-alias * Some infra for sql:sync under Docker transport * Update docs for new namespacing * Fix typo in docs. * React to slight change in AliasRecord::isRemote(). * Back out the sql:sync experiment. * Update composer/scenario files for consolidation releases
1 parent 939e080 commit 7b2fd7d

File tree

11 files changed

+224
-83
lines changed

11 files changed

+224
-83
lines changed

.scenarios.lock/php5/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
"consolidation/filter-via-dot-access-data": "^0.4",
6464
"consolidation/output-formatters": "^3.3.1",
6565
"consolidation/robo": "^1.3.4",
66-
"consolidation/site-alias": "^1.1.6|^2",
67-
"consolidation/site-process": "^0.1.18",
66+
"consolidation/site-alias": "^2.1.1",
67+
"consolidation/site-process": "^0.1.19",
6868
"grasmash/yaml-expander": "^1.1.1",
6969
"league/container": "~2",
7070
"psr/log": "~1.0",

.scenarios.lock/php5/composer.lock

Lines changed: 139 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
"consolidation/filter-via-dot-access-data": "^0.4",
4040
"consolidation/output-formatters": "^3.3.1",
4141
"consolidation/robo": "^1.3.4",
42-
"consolidation/site-alias": "^1.1.6|^2",
43-
"consolidation/site-process": "^0.1.18",
42+
"consolidation/site-alias": "^2.1.1",
43+
"consolidation/site-process": "^0.1.19",
4444
"grasmash/yaml-expander": "^1.1.1",
4545
"league/container": "~2",
4646
"psr/log": "~1.0",

composer.lock

Lines changed: 52 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/example.site.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121

122122
# Environment variables:
123123
#
124-
# It is no longer possible to set environment variables from within an alias.
124+
# SSH environments may no longer possible set environment variables from within an alias.
125125
# This is a planned feature.
126126

127127
# Additional Site Alias Options
@@ -130,6 +130,10 @@
130130
# local or remote Drupal installations; however, an alias
131131
# is really nothing more than a collection of options.
132132
#
133+
# - 'docker': When specified, Drush executes via docker-compose exec rather than ssh
134+
# - 'service': the name of the container to run on.
135+
# - 'exec':
136+
# - 'options': Options for the exec subcommand.
133137
# - 'os': The operating system of the remote server. Valid values
134138
# are 'Windows' and 'Linux'. Be sure to set this value for all remote
135139
# aliases because the default value is PHP_OS if 'remote-host'
@@ -223,6 +227,12 @@
223227
#
224228
# @code
225229
# # File: mysite.site.yml
230+
# local:
231+
# This environment is an example of the DockerCompose transport.
232+
# docker:
233+
# service: drupal
234+
# exec:
235+
# options: --user USER
226236
# stage:
227237
# uri: http://stage.example.com
228238
# root: /path/to/remote/drupal/root

src/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ protected function bootstrapAndFind($name)
209209
// Is the unknown command destined for a remote site?
210210
if ($this->aliasManager) {
211211
$selfAlias = $this->aliasManager->getSelf();
212-
if ($selfAlias->isRemote()) {
212+
if (!$selfAlias->isLocal()) {
213213
$command = new RemoteCommandProxy($name, $this->redispatchHook);
214214
$command->setApplication($this);
215215
return $command;

src/Commands/core/BrowseCommands.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function browse($path = '', array $options = ['browser' => self::REQ, 're
3737
$aliasRecord = $this->siteAliasManager()->getSelf();
3838
// Redispatch if called against a remote-host so a browser is started on the
3939
// the *local* machine.
40-
if ($aliasRecord->isRemote()) {
40+
if (!$aliasRecord->isLocal()) {
4141
$process = Drush::drush($aliasRecord, 'browse', [$path], Drush::redispatchOptions());
4242
$process->mustRun();
4343
$link = $process->getOutput();

src/Commands/core/LoginCommands.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function login($path = '', $options = ['name' => '1', 'browser' => true,
3939
// Redispatch if called against a remote-host so a browser is started on the
4040
// the *local* machine.
4141
$aliasRecord = $this->siteAliasManager()->getSelf();
42-
if ($aliasRecord->isRemote()) {
42+
if (!$aliasRecord->isLocal()) {
4343
$process = Drush::drush($aliasRecord, 'user-login', [$path], Drush::redispatchOptions());
4444
$process->mustRun();
4545
$link = $process->getOutput();

src/Commands/sql/SqlSyncCommands.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function validate(CommandData $commandData)
109109

110110
public function databaseName(AliasRecord $record)
111111
{
112-
if ($record->isRemote() && Drush::simulate()) {
112+
if (!$record->isLocal() && Drush::simulate()) {
113113
return 'simulated_db';
114114
}
115115

src/Drush.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public static function drush(AliasRecord $siteAlias, $command, $args = [], $opti
306306
*/
307307
public static function drushSiteProcess(AliasRecord $siteAlias, $args = [], $options = [], $options_double_dash = [])
308308
{
309-
$defaultDrushScript = $siteAlias->isRemote() ? 'drush' : static::drushScript();
309+
$defaultDrushScript = !$siteAlias->isLocal() ? 'drush' : static::drushScript();
310310

311311
// Fill in the root and URI from the site alias, if the caller
312312
// did not already provide them in $options.

0 commit comments

Comments
 (0)