Skip to content

Conversation

chriszarate
Copy link
Contributor

  • Introduce a new <scheme>: prefix to the connection string provided to --ssh. Current accepted values are docker:, docker-compose:, and ssh:. This prefix can be omitted and a default of ssh: will be assumed.

  • Additionally make the <user>@ option an explicit value separate from <host> so that it can be passed via CLI flag to Docker processes.

  • Refactor the Runner#run_ssh_command method to respond to different schemes.

  • Update existing functional test to accept escaped output. (Debug output of the unescaped command was removed during refactor to simplify the implementation.)

  • Add unit tests for updated parse_ssh_url.

  • Add functional test for docker: prefix.

  • Remove --ssh global flag from 40-column wrap test. The help text for the --ssh flag is now an unwrappable 61 characters long, leads to a failed functional test in help.feature. Strip out the --ssh global flag before passing to wc -L. Not sure what the best solution is here; this seemed like the most straightforward to me.

@chriszarate
Copy link
Contributor Author

After #4241 is addressed/merged, I can rebase so that tests pass.

- Introduce a new `<scheme>:` prefix to the connection string provided
  to `--ssh`. Current accepted values are `docker:`, `docker-compose:`,
  and `ssh:`. This prefix can be omitted and a default of `ssh:` will be
  assumed.

- Additionally make the `<user>@` option an explicit value separate from
  `<host>` so that it can be passed via CLI flag to Docker processes.

- Refactor the `Runner#run_ssh_command` method to respond to different
  schemes.

- Update existing functional test to accept escaped output. (Debug output
  of the unescaped command was removed during refactor to simplify the
  implementation.)

- Add unit tests for updated `parse_ssh_url`.

- Add functional test for `docker:` prefix.
The help text for the `--ssh` flag is now an unwrappable 61 characters
long, leads to a failed functional test in `help.feature`. Strip out
the `--ssh` global flag before passing to `wc -L`.
if ( $path ) {
$pre_cmd .= "cd {$path}; ";
if ( ! empty( $bits['path'] ) ) {
$pre_cmd .= 'cd ' . escapeshellarg( $bits['path'] ) . '; ';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it would be better to set/override the --path arg below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you think it would be better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder so many things; I should probably try to cut down. General uninformed feeling:

  1. Less code, takes advantage of built-in escaping below.
  2. Doing it "the WP-CLI way."
  3. Currently, if user supplies path in connection string AND --path arg, the --path arg "wins" even though it's not clear why or how.

After writing out point 3, though, I realize changing it would be rather arbitrary. If we wanted to be explicit, we could just drop support for path in the connection string and direct users to the --path arg.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying, @chriszarate.

At this point, my preference would be to keep the behavior as it exists. The original decision was intentional: mimic the behavior of ssh'ing to a specific directory, and then running the wp executable. This lets you use a project-specific wp-cli.yml if you have multiple projects on the server.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

@danielbachhuber
Copy link
Member

@chriszarate This looks pretty good to me. Thanks for taking the time to write out the unit tests too.

Is there any remaining work you'd like to perform on the PR before I merge?

@chriszarate
Copy link
Contributor Author

@danielbachhuber No, no remaining work from me. Thanks!

@danielbachhuber
Copy link
Member

👌 Thanks for your work on this!

@drzraf
Copy link
Contributor

drzraf commented Jun 11, 2018

This change did not considered the -i option of docker exec.
Without this, stdin can not be passed which keeps wp db import from running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants