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

Remove alias parameters. #3079

Merged
merged 4 commits into from
Oct 25, 2017
Merged
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
10 changes: 0 additions & 10 deletions examples/example.aliases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@
# - `drush sql-sync @live @stage`
# NOTE: Setting boolean options broke with Symfony 3. This will be fixed
# in a future release. See: https://github.com/drush-ops/drush/issues/2956
# - 'alias-parameters': These options will only be set if the alias is
# used as the specified parameter. `sql:sync` and `core:rsync` are the two
# core commands that use this entry. These commands both have `source`
# and `target` parameters.
#
# Complex example:
#
Expand All @@ -202,12 +198,6 @@
# install:
# options:
# admin-password: 'secret-secret'
# alias-parameters:
# target:
# core:
# rsnyc:
# options:
# exclude-paths: sites/default/files/private
# @endcode
#
# Altering aliases:
Expand Down
3 changes: 0 additions & 3 deletions src/Commands/core/RsyncCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ protected function injectAliasPathParameterOptions($input, $parameterName)

$aliasRecord = $evaluatedPath->getAliasRecord();

// Inject the source and target alias records into the alias config context.
$aliasRecord->injectIntoConfig($aliasConfigContext, $parameterName);

// If the path is remote, then we will also inject the global
// options into the alias config context so that we pick up
// things like ssh-options.
Expand Down
30 changes: 0 additions & 30 deletions src/Commands/sql/SqlSyncCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,36 +137,6 @@ public function sqlsync($source, $target, $options = ['no-dump' => false, 'no-sy
}
}

/**
* Inject options from source and target alias parameters.
*
* @hook command-event sql:sync
* @param ConsoleCommandEvent $event
*/
public function preCommandEvent(ConsoleCommandEvent $event)
{
$input = $event->getInput();
$this->injectAliasPathParameterOptions($input, 'source');
$this->injectAliasPathParameterOptions($input, 'target');
}

protected function injectAliasPathParameterOptions($input, $parameterName)
{
// The Drush configuration object is a ConfigOverlay; fetch the alias
// context, that already has the options et. al. from the
// site-selection alias ('drush @site rsync ...'), @self.
$aliasConfigContext = $this->getConfig()->getContext(ConfigLocator::ALIAS_CONTEXT);
$manager = $this->siteAliasManager();

$aliasName = $input->getArgument($parameterName);

// Inject the source and target alias records into the alias config context.
$aliasRecord = $manager->get($aliasName);
if (!empty($aliasRecord)) {
$manager->get($aliasName)->injectIntoConfig($aliasConfigContext, $parameterName);
}
}

/**
* @hook validate sql-sync
*/
Expand Down
22 changes: 0 additions & 22 deletions src/SiteAlias/AliasRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,28 +253,6 @@ protected function remap($data)
return new Config($data);
}

/**
* Copy options from the source and destination aliases into the
* alias context.
*
* This is essentially an `export` followed by `$config->combine()`.
* Parameter-specific options from the alias-parameters are also included.
*
* @param Config $config
* @param string $parameterName
* @return $this
*/
public function injectIntoConfig($config, $parameterName = '')
{
$aliasData = $this->export();
$parameterSpecificData = $this->getParameterSpecificOptions($aliasData, $parameterName);
if (!empty($parameterSpecificData)) {
// Combine the data from the parameter-specific
$config->combine($parameterSpecificData);
}
return $this;
}

/**
* Fetch the parameter-specific options from the 'alias-parameters' section of the alias.
* @param string $parameterName
Expand Down
36 changes: 10 additions & 26 deletions tests/resources/alias-fixtures/example.alias.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,19 @@
dev:
root: /path/to/dev
uri: dev
alias-parameters:
source:
command:
core:
rsync:
options:
include-paths: dev-source
target:
command:
core:
rsync:
options:
exclude-paths: dev-target
command:
core:
rsync:
options:
include-paths: dev-path
stage:
root: /path/to/stage
uri: stage
alias-parameters:
source:
command:
core:
rsync:
options:
include-paths: stage-source
target:
command:
core:
rsync:
options:
exclude-paths: stage-target
command:
core:
rsync:
options:
exclude-paths: stage-path
live:
user: www-admin
host: service-provider.com
Expand Down
6 changes: 3 additions & 3 deletions tests/rsyncTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ public function testSimulated() {

// Test simulated simple rsync with two local sites
$this->drush('rsync', ['@example.stage', '@example.dev'], $options, NULL, NULL, self::EXIT_SUCCESS, '2>&1');
$expected = "Calling system(rsync -e 'ssh ' -akz --include=\"stage-source\" --exclude=\"dev-target\" /path/to/stage /path/to/dev);";
$expected = "Calling system(rsync -e 'ssh ' -akz /path/to/stage /path/to/dev);";
$this->assertOutputEquals($expected);

// Test simulated rsync with relative paths
$this->drush('rsync', ['@example.dev:files', '@example.stage:files'], $options, NULL, NULL, self::EXIT_SUCCESS, '2>&1');
$expected = "Calling system(rsync -e 'ssh ' -akz --include=\"dev-source\" --exclude=\"stage-target\" /path/to/dev/files /path/to/stage/files);";
$expected = "Calling system(rsync -e 'ssh ' -akz /path/to/dev/files /path/to/stage/files);";
$this->assertOutputEquals($expected);

// Test simulated rsync on local machine with a remote target
$this->drush('rsync', ['@example.dev:files', '@example.live:files'], $options, NULL, NULL, self::EXIT_SUCCESS, '2>&1');
$expected = "Calling system(rsync -e 'ssh -o PasswordAuthentication=example' -akz --include=\"dev-source\" /path/to/dev/files www-admin@service-provider.com:/path/on/service-provider/files);";
$expected = "Calling system(rsync -e 'ssh -o PasswordAuthentication=example' -akz /path/to/dev/files www-admin@service-provider.com:/path/on/service-provider/files);";
$this->assertOutputEquals($expected);

// Test simulated backend invoke.
Expand Down