commit platformsh-cli for openSUSE:Factory
Hello community, here is the log from the commit of package platformsh-cli for openSUSE:Factory checked in at 2019-06-01 09:57:34 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/platformsh-cli (Old) and /work/SRC/openSUSE:Factory/.platformsh-cli.new.5148 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "platformsh-cli" Sat Jun 1 09:57:34 2019 rev:73 rq:706542 version:3.41.1 Changes: -------- --- /work/SRC/openSUSE:Factory/platformsh-cli/platformsh-cli.changes 2019-05-20 10:29:35.653892459 +0200 +++ /work/SRC/openSUSE:Factory/.platformsh-cli.new.5148/platformsh-cli.changes 2019-06-01 09:57:35.955156908 +0200 @@ -1,0 +2,23 @@ +Thu May 30 19:41:54 UTC 2019 - jimmy@boombatower.com + +- Update to version 3.41.1: + * Release v3.41.1 + * Remove redundant package + * Update client to incorporate guzzle/oauth2 bugfix + +------------------------------------------------------------------- +Wed May 29 19:38:20 UTC 2019 - jimmy@boombatower.com + +- Update to version 3.41.0: + * Release v3.41.0 + * Add --worker option to log command + * Support interactive worker selection in ssh command + * Support --worker option for mount commands + * Add environment commit SHA to the deployment cache key + * Allow a nonexistent --target in mount:download + * Update cweagans/composer-patches [skip changelog] + * getProject()'s cache should require the $host to match if one is specified (#799) + * Default config file should be .bash_profile on OS X (#798) + * Update autocompletion library (stecman/symfony-console-completion) + +------------------------------------------------------------------- Old: ---- platformsh-cli-3.40.16.tar.xz New: ---- platformsh-cli-3.41.1.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ platformsh-cli.spec ++++++ --- /var/tmp/diff_new_pack.yV4EXI/_old 2019-06-01 09:57:36.939156453 +0200 +++ /var/tmp/diff_new_pack.yV4EXI/_new 2019-06-01 09:57:36.947156450 +0200 @@ -17,7 +17,7 @@ Name: platformsh-cli -Version: 3.40.16 +Version: 3.41.1 Release: 0 Summary: Tool for managing Platform.sh services from the command line # See licenses.txt for dependency licenses. ++++++ _service ++++++ --- /var/tmp/diff_new_pack.yV4EXI/_old 2019-06-01 09:57:36.995156427 +0200 +++ /var/tmp/diff_new_pack.yV4EXI/_new 2019-06-01 09:57:36.995156427 +0200 @@ -2,7 +2,7 @@ <service name="tar_scm" mode="disabled"> <param name="versionformat">@PARENT_TAG@</param> <param name="versionrewrite-pattern">v(.*)</param> - <param name="revision">refs/tags/v3.40.16</param> + <param name="revision">refs/tags/v3.41.1</param> <param name="url">git://github.com/platformsh/platformsh-cli.git</param> <param name="scm">git</param> <param name="changesgenerate">enable</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.yV4EXI/_old 2019-06-01 09:57:37.023156415 +0200 +++ /var/tmp/diff_new_pack.yV4EXI/_new 2019-06-01 09:57:37.023156415 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">git://github.com/platformsh/platformsh-cli.git</param> - <param name="changesrevision">b4e39ae732091f6d18100931dcc40173b8d8f211</param> + <param name="changesrevision">e22256326f0aff49c7dc0e8e7c44314dae4d9354</param> </service> </servicedata> ++++++ extensions.txt ++++++ --- /var/tmp/diff_new_pack.yV4EXI/_old 2019-06-01 09:57:37.047156404 +0200 +++ /var/tmp/diff_new_pack.yV4EXI/_new 2019-06-01 09:57:37.047156404 +0200 @@ -10,16 +10,16 @@ [5] => php >=5.2.0 [6] => php >=5.3.0 [7] => php >=5.3.0 - [8] => php >=5.3.0 - [9] => php >=5.3.2 + [8] => php >=5.3.2 + [9] => php >=5.3.3 [10] => php >=5.3.3 [11] => php >=5.3.3 - [12] => php >=5.3.3 + [12] => php >=5.4.0 [13] => php >=5.4.0 [14] => php >=5.4.0 [15] => php >=5.4.0 [16] => php >=5.4.0 - [17] => php >=5.4.0 + [17] => php >=5.5.9 [18] => php >=5.5.9 [19] => php >=5.5.9 [20] => php >=5.5.9 ++++++ licenses.txt ++++++ --- /var/tmp/diff_new_pack.yV4EXI/_old 2019-06-01 09:57:37.079156389 +0200 +++ /var/tmp/diff_new_pack.yV4EXI/_new 2019-06-01 09:57:37.079156389 +0200 @@ -5,9 +5,7 @@ Name Version License cocur/slugify v2.5 MIT -commerceguys/guzzle-oauth2-plugin v2.1.1 MIT composer/ca-bundle 1.1.4 MIT -cweagans/composer-patches 1.6.5 BSD-3-Clause doctrine/cache v1.6.2 MIT firebase/php-jwt v2.2.0 BSD-3-Clause guzzlehttp/cache-subscriber 0.1.0 MIT @@ -17,12 +15,13 @@ padraic/humbug_get_contents 1.1.2 BSD-3-Clause padraic/phar-updater v1.0.6 BSD-3-Clause paragonie/random_compat v2.0.18 MIT -platformsh/client v0.24.1 MIT +pjcdawkins/guzzle-oauth2-plugin v2.2.0 MIT +platformsh/client v0.25.2 MIT platformsh/console-form v0.0.23 MIT psr/container 1.0.0 MIT psr/log 1.1.0 MIT react/promise v2.7.1 MIT -stecman/symfony-console-completion 0.8.0 MIT +stecman/symfony-console-completion 0.10.1 MIT symfony/config v3.4.27 MIT symfony/console v3.4.27 MIT symfony/debug v3.4.27 MIT ++++++ platformsh-cli-3.40.16.tar.xz -> platformsh-cli-3.41.1.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/composer.json new/platformsh-cli-3.41.1/composer.json --- old/platformsh-cli-3.40.16/composer.json 2019-05-18 21:59:27.000000000 +0200 +++ new/platformsh-cli-3.41.1/composer.json 2019-05-29 23:19:27.000000000 +0200 @@ -8,13 +8,13 @@ "guzzlehttp/guzzle": "^5.3", "guzzlehttp/ringphp": "^1.1", "platformsh/console-form": ">=0.0.22 <2.0", - "platformsh/client": ">=0.24.0 <2.0", + "platformsh/client": ">=0.25.2 <2.0", "symfony/console": "^3.0 >=3.2", "symfony/yaml": "^3.0 || ^2.6", "symfony/finder": "^3.0", "symfony/filesystem": "^3.0", "symfony/process": "^3.0 >=3.4", - "stecman/symfony-console-completion": "^0.8 >=0.8", + "stecman/symfony-console-completion": "^0.10", "symfony/event-dispatcher": "^3.0", "padraic/phar-updater": "^1.0", "symfony/dependency-injection": "^3.1", @@ -52,11 +52,6 @@ "bin": [ "bin/platform" ], - "extra": { - "patches": { - "commerceguys/guzzle-oauth2-plugin": {} - } - }, "config": { "platform": { "php": "5.5.9" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/composer.lock new/platformsh-cli-3.41.1/composer.lock --- old/platformsh-cli-3.40.16/composer.lock 2019-05-18 21:59:27.000000000 +0200 +++ new/platformsh-cli-3.41.1/composer.lock 2019-05-29 23:19:27.000000000 +0200 @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ff150a4f33c6f02f96851418ab04c85f", + "content-hash": "c9690d2fdb88a309e4219d07b8ae43a9", "packages": [ { "name": "cocur/slugify", @@ -71,57 +71,6 @@ "time": "2017-03-23T21:52:55+00:00" }, { - "name": "commerceguys/guzzle-oauth2-plugin", - "version": "v2.1.1", - "source": { - "type": "git", - "url": "https://github.com/commerceguys/guzzle-oauth2-plugin.git", - "reference": "f7ed19171c3c5accfb6f0b3d1209eb5815ef8148" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/commerceguys/guzzle-oauth2-plugin/zipball/f7ed1...", - "reference": "f7ed19171c3c5accfb6f0b3d1209eb5815ef8148", - "shasum": "" - }, - "require": { - "firebase/php-jwt": "~2.0", - "guzzlehttp/guzzle": "~5.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.5" - }, - "type": "library", - "extra": { - "patches_applied": { - "Make it possible to get the access token without triggering a refresh": "https://github.com/pjcdawkins/guzzle-oauth2-plugin/commit/d2d720015813185d1a...", - "Support a token save callback": "https://github.com/commerceguys/guzzle-oauth2-plugin/compare/master...pjcdaw..." - } - }, - "autoload": { - "psr-4": { - "CommerceGuys\\Guzzle\\Oauth2\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bojan Zivanovic" - }, - { - "name": "Damien Tournoud" - }, - { - "name": "Patrick Dawkins" - } - ], - "description": "An OAuth2 plugin (subscriber) for Guzzle", - "time": "2015-12-12T23:27:25+00:00" - }, - { "name": "composer/ca-bundle", "version": "1.1.4", "source": { @@ -178,50 +127,6 @@ "time": "2019-01-28T09:30:10+00:00" }, { - "name": "cweagans/composer-patches", - "version": "1.6.5", - "source": { - "type": "git", - "url": "https://github.com/cweagans/composer-patches.git", - "reference": "2ec4f00ff5fb64de584c8c4aea53bf9053ecb0b3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/cweagans/composer-patches/zipball/2ec4f00ff5fb6...", - "reference": "2ec4f00ff5fb64de584c8c4aea53bf9053ecb0b3", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0", - "php": ">=5.3.0" - }, - "require-dev": { - "composer/composer": "~1.0", - "phpunit/phpunit": "~4.6" - }, - "type": "composer-plugin", - "extra": { - "class": "cweagans\\Composer\\Patches" - }, - "autoload": { - "psr-4": { - "cweagans\\Composer\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Cameron Eagans", - "email": "me@cweagans.net" - } - ], - "description": "Provides a way to patch Composer packages.", - "time": "2018-05-11T18:00:16+00:00" - }, - { "name": "doctrine/cache", "version": "v1.6.2", "source": { @@ -712,38 +617,75 @@ "time": "2019-01-03T20:59:08+00:00" }, { + "name": "pjcdawkins/guzzle-oauth2-plugin", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/pjcdawkins/guzzle-oauth2-plugin.git", + "reference": "4bbb1261a18f419f5fe1f15cdf47d384cc94cfe0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pjcdawkins/guzzle-oauth2-plugin/zipball/4bbb126...", + "reference": "4bbb1261a18f419f5fe1f15cdf47d384cc94cfe0", + "shasum": "" + }, + "require": { + "firebase/php-jwt": "~2.0", + "guzzlehttp/guzzle": "~5.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "CommerceGuys\\Guzzle\\Oauth2\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bojan Zivanovic" + }, + { + "name": "Damien Tournoud" + }, + { + "name": "Patrick Dawkins" + } + ], + "description": "An OAuth2 plugin (subscriber) for Guzzle (forked from commerceguys/guzzle-oauth2-plugin)", + "time": "2019-05-29T20:51:02+00:00" + }, + { "name": "platformsh/client", - "version": "v0.24.1", + "version": "v0.25.2", "source": { "type": "git", "url": "https://github.com/platformsh/platformsh-client-php.git", - "reference": "f17027d031bf8a05dddf6dd133d835e055837f93" + "reference": "8f4d305d80a6a68d6cc8c0e10cadbb063c30963a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/platformsh/platformsh-client-php/zipball/f17027...", - "reference": "f17027d031bf8a05dddf6dd133d835e055837f93", + "url": "https://api.github.com/repos/platformsh/platformsh-client-php/zipball/8f4d30...", + "reference": "8f4d305d80a6a68d6cc8c0e10cadbb063c30963a", "shasum": "" }, "require": { "cocur/slugify": "^2.0 || ~1.0", - "commerceguys/guzzle-oauth2-plugin": "~2.0", - "cweagans/composer-patches": "~1.0", "guzzlehttp/cache-subscriber": "~0.1", - "guzzlehttp/guzzle": "~5.3" + "guzzlehttp/guzzle": "~5.3", + "php": ">=5.5.9", + "pjcdawkins/guzzle-oauth2-plugin": "^2.2" }, "require-dev": { "phpunit/phpunit": "~4.5" }, "type": "library", - "extra": { - "patches": { - "commerceguys/guzzle-oauth2-plugin": { - "Make it possible to get the access token without triggering a refresh": "https://github.com/pjcdawkins/guzzle-oauth2-plugin/commit/d2d720015813185d1a...", - "Support a token save callback": "https://github.com/commerceguys/guzzle-oauth2-plugin/compare/master...pjcdaw..." - } - } - }, "autoload": { "psr-4": { "Platformsh\\Client\\": "src" @@ -759,7 +701,7 @@ } ], "description": "Platform.sh API client", - "time": "2019-05-12T13:50:12+00:00" + "time": "2019-05-29T21:09:28+00:00" }, { "name": "platformsh/console-form", @@ -944,16 +886,16 @@ }, { "name": "stecman/symfony-console-completion", - "version": "0.8.0", + "version": "0.10.1", "source": { "type": "git", "url": "https://github.com/stecman/symfony-console-completion.git", - "reference": "cd738867503477e91dbe84173dfabd431c883431" + "reference": "7bfa9b93e216896419f2f8de659935d7e04fecd8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/stecman/symfony-console-completion/zipball/cd73...", - "reference": "cd738867503477e91dbe84173dfabd431c883431", + "url": "https://api.github.com/repos/stecman/symfony-console-completion/zipball/7bfa...", + "reference": "7bfa9b93e216896419f2f8de659935d7e04fecd8", "shasum": "" }, "require": { @@ -966,7 +908,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "0.6.x-dev" + "dev-master": "0.10.x-dev" } }, "autoload": { @@ -985,7 +927,7 @@ } ], "description": "Automatic BASH completion for Symfony Console Component based applications.", - "time": "2018-02-10T04:28:01+00:00" + "time": "2019-04-29T03:20:18+00:00" }, { "name": "symfony/config", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/dist/manifest.json new/platformsh-cli-3.41.1/dist/manifest.json --- old/platformsh-cli-3.40.16/dist/manifest.json 2019-05-18 21:59:27.000000000 +0200 +++ new/platformsh-cli-3.41.1/dist/manifest.json 2019-05-29 23:19:27.000000000 +0200 @@ -1,10 +1,10 @@ [ { "name": "platform.phar", - "sha1": "39a614305bff7b91516df58c463f2fc9c7936bb7", - "sha256": "08af6ff280b6d7a8a1e0397752ca9816a980b07c16f072ddad074c928b04ea66", - "url": "https://github.com/platformsh/platformsh-cli/releases/download/v3.40.16/plat...", - "version": "3.40.16", + "sha1": "7debcbd5d598319bb7c1bcbb9ecf4a3ecc97c28c", + "sha256": "700ee2b7450ee9008d1d824dae7d9d745a7c0122af445e8eb086fc5048536175", + "url": "https://github.com/platformsh/platformsh-cli/releases/download/v3.41.1/platf...", + "version": "3.41.1", "php": { "min": "5.5.9" }, @@ -172,6 +172,11 @@ "notes": "New features:\n\n* Support multiple schemas per database relationship:\n - Add --schema option to `db:dump` and `db:sql` commands.\n - Include the service name and schema in the `db:dump` default filename.\n - Present a choice between schemas if no schema is specified.\n - Make `db:size` schema agnostic but warn about inaccessible schemas.\n\nBug fixes:\n\n* Use a different Drush alias root for site-local versions 8 or 9. Drush 9\n fails to find a Drupal root via a relative path in some circumstances.\n* Fix behavior of choice questions with no default in non-interactive mode.\n* Fix checkout command when there is only one branch.\n* Fix Drush lock files not being used in local:build command.\n\nOther changes:\n\n* Add some 3-letter command aliases:\n - activity:list => activities => act\n - environment:list => environments => env\n - project:list => projects => pro\n - variable:list => variables => var", "show from": "3.39.0", "hide from": "3.40.0" + }, + { + "notes": "New features:\n\n* Better worker support:\n - Improve worker selection in the environment:ssh (ssh) command.\n - Add the --worker option to all mount commands.\n - Add the --worker option to the environment:logs (log) command.\n - If --app or --worker is not provided, the above commands will now prompt you\n to choose between the app(s) or their worker(s).\n* Allow a nonexistent --target directory in the mount:download command (prompt\n to create it).\n\nBug fixes:\n\n* Add environment commit SHA to the deployment cache key\n This ensures old deployment information is not used when we know the environment\n has changed.\n* Ensure migrated projects on a new host do not use cached information from the\n old host.\n* Installer: the default config file should be .bash_profile on OS X.\n\nOther changes:\n\n* Update autocompletion library (stecman/symfony-console-completion)\n Highlights:\n - \"Adds support for quoted and escaped multi-word completions\"\n - \"Fixes options appearing before the command name (eg. `program -v cmdname`)\n breaking the detection of the command that should be completed for\"", + "show from": "3.40.0", + "hide from": "3.41.0" } ] } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/src/Command/CommandBase.php new/platformsh-cli-3.41.1/src/Command/CommandBase.php --- old/platformsh-cli-3.40.16/src/Command/CommandBase.php 2019-05-18 21:59:27.000000000 +0200 +++ new/platformsh-cli-3.41.1/src/Command/CommandBase.php 2019-05-29 23:19:27.000000000 +0200 @@ -7,6 +7,7 @@ use Platformsh\Cli\Exception\ProjectNotFoundException; use Platformsh\Cli\Exception\RootNotFoundException; use Platformsh\Cli\Local\BuildFlavor\Drupal; +use Platformsh\Cli\Model\SshDestination; use Platformsh\Client\Exception\EnvironmentStateException; use Platformsh\Client\Model\Deployment\WebApp; use Platformsh\Client\Model\Environment; @@ -808,7 +809,161 @@ } /** - * Find the name of the app the user wants to use for an SSH command. + * Add the --app and --worker options. + */ + protected function addSshDestinationOptions() + { + if (!$this->getDefinition()->hasOption('app')) { + $this->addAppOption(); + } + if (!$this->getDefinition()->hasOption('worker')) { + $this->addOption('worker', null, InputOption::VALUE_REQUIRED, 'A worker name'); + } + } + + /** + * Find what app or worker the user wants to SSH to. + * + * Requires the --app and --worker options to be present. + * + * @param InputInterface $input + * The user input object. + * + * @return \Platformsh\Cli\Model\SshDestination\SshDestinationInterface + * An SSH destination. + */ + protected function selectSshDestination(InputInterface $input) + { + $environment = $this->getSelectedEnvironment(); + $deployment = $this->api()->getCurrentDeployment($environment, $input->hasOption('refresh') ? $input->getOption('refresh') : null); + + // Validate the --app option, without doing anything with it. + $appOption = $input->hasOption('app') ? $input->getOption('app') : null; + if ($appOption !== null) { + try { + $deployment->getWebApp($appOption); + } catch (\InvalidArgumentException $e) { + throw new ConsoleInvalidArgumentException('Application not found: ' . $appOption); + } + } + + // Handle the --worker option first, as it's more specific. + $workerOption = $input->hasOption('worker') ? $input->getOption('worker') : null; + if ($workerOption !== null) { + // Check for a conflict with the --app option. + if ($appOption !== null + && strpos($workerOption, '--') !== false + && stripos($workerOption, $appOption . '--') !== 0) { + throw new \InvalidArgumentException(sprintf( + 'App name "%s" conflicts with worker name "%s"', + $appOption, + $workerOption + )); + } + + // If we have the app name, load the worker directly. + if (strpos($workerOption, '--') !== false || $appOption !== null) { + $qualifiedWorkerName = strpos($workerOption, '--') !== false + ? $workerOption + : $appOption . '--' . $workerOption; + try { + $worker = $deployment->getWorker($qualifiedWorkerName); + } catch (\InvalidArgumentException $e) { + throw new ConsoleInvalidArgumentException('Worker not found: ' . $workerOption); + } + + return new SshDestination\Worker($worker, $environment); + } + + // If we don't have the app name, find all the possible matching + // workers, and ask the user to choose. + $suffix = '--' . $workerOption; + $suffixLength = strlen($suffix); + $workerNames = []; + foreach ($deployment->workers as $worker) { + if (substr($worker->name, -$suffixLength) === $suffix) { + $workerNames[] = $worker->name; + } + } + if (count($workerNames) === 0) { + throw new ConsoleInvalidArgumentException('Worker not found: ' . $workerOption); + } + if (count($workerNames) === 1) { + $workerName = reset($workerNames); + + return new SshDestination\Worker($deployment->getWorker($workerName), $environment); + } + if (!$input->isInteractive()) { + throw new ConsoleInvalidArgumentException(sprintf( + 'Ambiguous worker name: %s (matches: %s)', + $workerOption, + implode(', ', $workerNames) + )); + } + /** @var \Platformsh\Cli\Service\QuestionHelper $questionHelper */ + $questionHelper = $this->getService('question_helper'); + $workerName = $questionHelper->choose( + $workerNames, + 'Enter a number to choose a worker:' + ); + + return new SshDestination\Worker($deployment->getWorker($workerName), $environment); + } + + // Prompt the user to choose between the app(s) or worker(s) that have + // been found. + $default = null; + $appNames = $appOption !== null + ? [$appOption] + : array_map(function (WebApp $app) { return $app->name; }, $deployment->webapps); + if (count($appNames) === 1) { + $default = reset($appNames); + $choices = []; + $choices[$default] = $default . ' (default)'; + } else { + $choices = array_combine($appNames, $appNames); + } + foreach ($deployment->workers as $worker) { + list($appPart, ) = explode('--', $worker->name, 2); + if (in_array($appPart, $appNames, true)) { + $choices[$worker->name] = $worker->name; + } + } + if (count($choices) === 0) { + throw new \RuntimeException('Failed to find apps or workers for environment: ' . $environment->id); + } + ksort($choices, SORT_NATURAL); + if (count($choices) === 1) { + $choice = key($choices); + } elseif ($input->isInteractive()) { + /** @var \Platformsh\Cli\Service\QuestionHelper $questionHelper */ + $questionHelper = $this->getService('question_helper'); + $choice = $questionHelper->choose( + $choices, + sprintf('Enter a number to choose %s app or %s worker:', + count($appNames) === 1 ? 'the' : 'an', + count($choices) === 2 ? 'its' : 'a' + ), + $default + ); + } elseif (count($appNames) === 1) { + $choice = reset($appNames); + } else { + throw new ConsoleInvalidArgumentException( + 'Specifying the --app or --worker is required in non-interactive mode' + ); + } + + // Match the choice to a worker or app destination. + if (strpos($choice, '--') !== false) { + return new SshDestination\Worker($deployment->getWorker($choice), $environment); + } + + return new SshDestination\App($deployment->getWebApp($choice), $environment); + } + + /** + * Find the name of the app the user wants to use. * * @param InputInterface $input * The user input object. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/src/Command/Environment/EnvironmentLogCommand.php new/platformsh-cli-3.41.1/src/Command/Environment/EnvironmentLogCommand.php --- old/platformsh-cli-3.40.16/src/Command/Environment/EnvironmentLogCommand.php 2019-05-18 21:59:27.000000000 +0200 +++ new/platformsh-cli-3.41.1/src/Command/Environment/EnvironmentLogCommand.php 2019-05-29 23:19:27.000000000 +0200 @@ -25,7 +25,7 @@ ->addOption('tail', null, InputOption::VALUE_NONE, 'Continuously tail the log'); $this->addProjectOption() ->addEnvironmentOption() - ->addAppOption(); + ->addSshDestinationOptions(); $this->setHiddenAliases(['logs']); $this->addExample('Display a choice of logs that can be read'); $this->addExample('Read the deploy log', 'deploy'); @@ -41,9 +41,8 @@ throw new InvalidArgumentException('The --tail option cannot be used with "multi"'); } - $selectedEnvironment = $this->getSelectedEnvironment(); - $appName = $this->selectApp($input); - $sshUrl = $selectedEnvironment->getSshUrl($appName); + $sshDestination = $this->selectSshDestination($input); + $sshUrl = $sshDestination->getSshUrl(); /** @var \Platformsh\Cli\Service\Shell $shell */ $shell = $this->getService('shell'); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/src/Command/Environment/EnvironmentSshCommand.php new/platformsh-cli-3.41.1/src/Command/Environment/EnvironmentSshCommand.php --- old/platformsh-cli-3.40.16/src/Command/Environment/EnvironmentSshCommand.php 2019-05-18 21:59:27.000000000 +0200 +++ new/platformsh-cli-3.41.1/src/Command/Environment/EnvironmentSshCommand.php 2019-05-29 23:19:27.000000000 +0200 @@ -25,8 +25,7 @@ ->setDescription('SSH to the current environment'); $this->addProjectOption() ->addEnvironmentOption() - ->addAppOption(); - $this->addOption('worker', null, InputOption::VALUE_REQUIRED, 'SSH to a worker'); + ->addSshDestinationOptions(); Ssh::configureInput($this->getDefinition()); $this->addExample('Read recent messages in the deploy log', "'tail /var/log/deploy.log'"); $this->addExample('Open a shell over SSH'); @@ -43,22 +42,8 @@ return 0; } - $appName = $this->selectApp($input); - $sshUrl = $environment->getSshUrl($appName); - - if ($worker = $input->getOption('worker')) { - // Validate the worker. - $deployment = $this->api()->getCurrentDeployment($environment); - try { - $deployment->getWorker($appName . '--' . $worker); - } catch (\InvalidArgumentException $e) { - $this->stdErr->writeln('Worker not found: <error>' . $worker . '</error>'); - - return 1; - } - list($username, $rest) = explode('@', $sshUrl, 2); - $sshUrl = $username . '--' . $worker . '@' . $rest; - } + $sshDestination = $this->selectSshDestination($input); + $sshUrl = $sshDestination->getSshUrl(); if ($input->getOption('pipe')) { $output->write($sshUrl); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/src/Command/Mount/MountCommandBase.php new/platformsh-cli-3.41.1/src/Command/Mount/MountCommandBase.php --- old/platformsh-cli-3.40.16/src/Command/Mount/MountCommandBase.php 2019-05-18 21:59:27.000000000 +0200 +++ new/platformsh-cli-3.41.1/src/Command/Mount/MountCommandBase.php 2019-05-29 23:19:27.000000000 +0200 @@ -3,29 +3,11 @@ namespace Platformsh\Cli\Command\Mount; use Platformsh\Cli\Command\CommandBase; -use Platformsh\Cli\Model\AppConfig; use Symfony\Component\Console\Output\OutputInterface; abstract class MountCommandBase extends CommandBase { /** - * Get the remote application config. - * - * @param string $appName - * @param bool $refresh - * - * @return array - */ - protected function getAppConfig($appName, $refresh = true) - { - $webApp = $this->api() - ->getCurrentDeployment($this->getSelectedEnvironment(), $refresh) - ->getWebApp($appName); - - return AppConfig::fromWebApp($webApp)->getNormalized(); - } - - /** * Format the mounts as an array of options for a ChoiceQuestion. * * @param array $mounts @@ -66,20 +48,17 @@ /** * Push the local contents to the chosen mount. * - * @param string $appName + * @param string $sshUrl * @param string $mountPath * @param string $localPath * @param bool $up * @param array $options */ - protected function runSync($appName, $mountPath, $localPath, $up, array $options = []) + protected function runSync($sshUrl, $mountPath, $localPath, $up, array $options = []) { /** @var \Platformsh\Cli\Service\Shell $shell */ $shell = $this->getService('shell'); - $sshUrl = $this->getSelectedEnvironment() - ->getSshUrl($appName); - $params = ['rsync', '--archive', '--compress', '--human-readable']; if ($this->stdErr->isVeryVerbose()) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/src/Command/Mount/MountDownloadCommand.php new/platformsh-cli-3.41.1/src/Command/Mount/MountDownloadCommand.php --- old/platformsh-cli-3.40.16/src/Command/Mount/MountDownloadCommand.php 2019-05-18 21:59:27.000000000 +0200 +++ new/platformsh-cli-3.41.1/src/Command/Mount/MountDownloadCommand.php 2019-05-29 23:19:27.000000000 +0200 @@ -27,7 +27,7 @@ ->addOption('refresh', null, InputOption::VALUE_NONE, 'Whether to refresh the cache'); $this->addProjectOption(); $this->addEnvironmentOption(); - $this->addAppOption(); + $this->addSshDestinationOptions(); } /** @@ -37,17 +37,17 @@ { $this->validateInput($input); - $appName = $this->selectApp($input); - $appConfig = $this->getAppConfig($appName, (bool) $input->getOption('refresh')); + $sshDestination = $this->selectSshDestination($input); + $mounts = $sshDestination->getMounts(); - if (empty($appConfig['mounts'])) { - $this->stdErr->writeln(sprintf('The app "%s" doesn\'t define any mounts.', $appConfig['name'])); + if (empty($mounts)) { + $this->stdErr->writeln(sprintf('The %s "%s" doesn\'t define any mounts.', $sshDestination->getType(), $sshDestination->getName())); return 1; } /** @var \Platformsh\Cli\Service\Mount $mountService */ $mountService = $this->getService('mount'); - $mounts = $mountService->normalizeMounts($appConfig['mounts']); + $mounts = $mountService->normalizeMounts($mounts); /** @var \Platformsh\Cli\Service\QuestionHelper $questionHelper */ $questionHelper = $this->getService('question_helper'); @@ -55,7 +55,7 @@ $fs = $this->getService('fs'); if ($input->getOption('mount')) { - $mountPath = $mountService->validateMountPath($input->getOption('mount'), $mounts); + $mountPath = $mountService->matchMountPath($input->getOption('mount'), $mounts); } elseif ($input->isInteractive()) { $mountPath = $questionHelper->choose( $this->getMountsAsOptions($mounts), @@ -72,7 +72,7 @@ if ($input->getOption('target')) { $target = $input->getOption('target'); } elseif ($projectRoot = $this->getProjectRoot()) { - $sharedMounts = $mountService->getSharedFileMounts($appConfig); + $sharedMounts = $mountService->getSharedFileMounts($mounts); if (isset($sharedMounts[$mountPath])) { if (file_exists($projectRoot . '/' . $this->config()->get('local.shared_dir') . '/' . $sharedMounts[$mountPath])) { $defaultTarget = $projectRoot . '/' . $this->config()->get('local.shared_dir') . '/' . $sharedMounts[$mountPath]; @@ -82,7 +82,7 @@ $applications = LocalApplication::getApplications($projectRoot, $this->config()); $appPath = $projectRoot; foreach ($applications as $path => $candidateApp) { - if ($candidateApp->getName() === $appName) { + if ($candidateApp->getName() === $sshDestination->getName()) { $appPath = $path; break; } @@ -108,7 +108,15 @@ return 1; } - $this->validateDirectory($target, true); + if (!file_exists($target)) { + // Allow rsync to create the target directory if it doesn't + // already exist. + if (!$questionHelper->confirm(sprintf('Directory not found: <comment>%s</comment>. Do you want to create it?', $target))) { + return 1; + } + } else { + $this->validateDirectory($target, true); + } $confirmText = sprintf( "\nDownloading files from the remote mount <comment>%s</comment> to <comment>%s</comment>" @@ -120,7 +128,7 @@ return 1; } - $this->runSync($appName, $mountPath, $target, false, [ + $this->runSync($sshDestination->getSshUrl(), $mountPath, $target, false, [ 'delete' => $input->getOption('delete'), 'exclude' => $input->getOption('exclude'), 'include' => $input->getOption('include'), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/src/Command/Mount/MountListCommand.php new/platformsh-cli-3.41.1/src/Command/Mount/MountListCommand.php --- old/platformsh-cli-3.40.16/src/Command/Mount/MountListCommand.php 2019-05-18 21:59:27.000000000 +0200 +++ new/platformsh-cli-3.41.1/src/Command/Mount/MountListCommand.php 2019-05-29 23:19:27.000000000 +0200 @@ -24,7 +24,7 @@ Table::configureInput($this->getDefinition()); $this->addProjectOption(); $this->addEnvironmentOption(); - $this->addAppOption(); + $this->addSshDestinationOptions(); } /** @@ -34,16 +34,18 @@ { $this->validateInput($input); - $appConfig = $this->getAppConfig($this->selectApp($input), (bool) $input->getOption('refresh')); + $sshDestination = $this->selectSshDestination($input); + $mounts = $sshDestination->getMounts(); - if (empty($appConfig['mounts'])) { - $this->stdErr->writeln(sprintf('The app "%s" doesn\'t define any mounts.', $appConfig['name'])); + if (empty($mounts)) { + $this->stdErr->writeln(sprintf('The %s "%s" doesn\'t define any mounts.', $sshDestination->getType(), $sshDestination->getName())); return 1; } + /** @var \Platformsh\Cli\Service\Mount $mountService */ $mountService = $this->getService('mount'); - $mounts = $mountService->normalizeMounts($appConfig['mounts']); + $mounts = $mountService->normalizeMounts($mounts); if ($input->getOption('paths')) { $output->writeln(array_keys($mounts)); @@ -61,7 +63,12 @@ /** @var \Platformsh\Cli\Service\Table $table */ $table = $this->getService('table'); - $this->stdErr->writeln(sprintf('Mounts in the app <info>%s</info> (environment <info>%s</info>):', $appConfig['name'], $this->getSelectedEnvironment()->id)); + $this->stdErr->writeln(sprintf( + 'Mounts in the %s <info>%s</info> (environment <info>%s</info>):', + $sshDestination->getType(), + $sshDestination->getName(), + $this->getSelectedEnvironment()->id + )); $table->render($rows, $header); return 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/src/Command/Mount/MountSizeCommand.php new/platformsh-cli-3.41.1/src/Command/Mount/MountSizeCommand.php --- old/platformsh-cli-3.40.16/src/Command/Mount/MountSizeCommand.php 2019-05-18 21:59:27.000000000 +0200 +++ new/platformsh-cli-3.41.1/src/Command/Mount/MountSizeCommand.php 2019-05-29 23:19:27.000000000 +0200 @@ -26,7 +26,7 @@ Ssh::configureInput($this->getDefinition()); $this->addProjectOption(); $this->addEnvironmentOption(); - $this->addAppOption(); + $this->addSshDestinationOptions(); $appConfigFile = $this->config()->get('service.app_config_file'); $this->setHelp(<<<EOF Use this command to check the disk size and usage for an application's mounts. @@ -46,21 +46,21 @@ { $this->validateInput($input); - $appName = $this->selectApp($input); + $sshDestination = $this->selectSshDestination($input); + $mounts = $sshDestination->getMounts(); - $appConfig = $this->getAppConfig($appName, $input->getOption('refresh')); - if (empty($appConfig['mounts'])) { - $this->stdErr->writeln(sprintf('The app "%s" doesn\'t define any mounts.', $appConfig['name'])); + if (empty($mounts)) { + $this->stdErr->writeln(sprintf('The %s "%s" doesn\'t define any mounts.', $sshDestination->getType(), $sshDestination->getName())); return 1; } - $this->stdErr->writeln(sprintf('Checking disk usage for all mounts of the application <info>%s</info>...', $appName)); + $this->stdErr->writeln(sprintf('Checking disk usage for all mounts of the %s <info>%s</info>...', $sshDestination->getType(), $sshDestination->getName())); // Get a list of the mount paths (and normalize them as relative paths, // relative to the application directory). $mountPaths = []; - foreach (array_keys($appConfig['mounts']) as $mountPath) { + foreach (array_keys($mounts) as $mountPath) { $mountPaths[] = trim(trim($mountPath), '/'); } @@ -88,7 +88,7 @@ // Connect to the application via SSH and run the commands. $sshArgs = [ 'ssh', - $this->getSelectedEnvironment()->getSshUrl($appName), + $sshDestination->getSshUrl(), ]; /** @var \Platformsh\Cli\Service\Ssh $ssh */ $ssh = $this->getService('ssh'); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/src/Command/Mount/MountUploadCommand.php new/platformsh-cli-3.41.1/src/Command/Mount/MountUploadCommand.php --- old/platformsh-cli-3.40.16/src/Command/Mount/MountUploadCommand.php 2019-05-18 21:59:27.000000000 +0200 +++ new/platformsh-cli-3.41.1/src/Command/Mount/MountUploadCommand.php 2019-05-29 23:19:27.000000000 +0200 @@ -27,7 +27,7 @@ ->addOption('refresh', null, InputOption::VALUE_NONE, 'Whether to refresh the cache'); $this->addProjectOption(); $this->addEnvironmentOption(); - $this->addAppOption(); + $this->addSshDestinationOptions(); } /** @@ -36,18 +36,18 @@ protected function execute(InputInterface $input, OutputInterface $output) { $this->validateInput($input); - $appName = $this->selectApp($input); - $appConfig = $this->getAppConfig($appName, (bool) $input->getOption('refresh')); + $sshDestination = $this->selectSshDestination($input); + $mounts = $sshDestination->getMounts(); - if (empty($appConfig['mounts'])) { - $this->stdErr->writeln(sprintf('The app "%s" doesn\'t define any mounts.', $appConfig['name'])); + if (empty($mounts)) { + $this->stdErr->writeln(sprintf('The %s "%s" doesn\'t define any mounts.', $sshDestination->getType(), $sshDestination->getName())); return 1; } /** @var \Platformsh\Cli\Service\Mount $mountService */ $mountService = $this->getService('mount'); - $mounts = $mountService->normalizeMounts($appConfig['mounts']); + $mounts = $mountService->normalizeMounts($mounts); /** @var \Platformsh\Cli\Service\QuestionHelper $questionHelper */ $questionHelper = $this->getService('question_helper'); @@ -55,7 +55,7 @@ $fs = $this->getService('fs'); if ($input->getOption('mount')) { - $mountPath = $mountService->validateMountPath($input->getOption('mount'), $mounts); + $mountPath = $mountService->matchMountPath($input->getOption('mount'), $mounts); } elseif ($input->isInteractive()) { $mountPath = $questionHelper->choose( $this->getMountsAsOptions($mounts), @@ -72,7 +72,7 @@ if ($input->getOption('source')) { $source = $input->getOption('source'); } elseif ($projectRoot = $this->getProjectRoot()) { - $sharedMounts = $mountService->getSharedFileMounts($appConfig); + $sharedMounts = $mountService->getSharedFileMounts($mounts); if (isset($sharedMounts[$mountPath])) { if (file_exists($projectRoot . '/' . $this->config()->get('local.shared_dir') . '/' . $sharedMounts[$mountPath])) { $defaultSource = $projectRoot . '/' . $this->config()->get('local.shared_dir') . '/' . $sharedMounts[$mountPath]; @@ -82,7 +82,7 @@ $applications = LocalApplication::getApplications($projectRoot, $this->config()); $appPath = $projectRoot; foreach ($applications as $path => $candidateApp) { - if ($candidateApp->getName() === $appName) { + if ($candidateApp->getName() === $sshDestination->getName()) { $appPath = $path; break; } @@ -120,7 +120,7 @@ return 1; } - $this->runSync($appName, $mountPath, $source, true, [ + $this->runSync($sshDestination->getSshUrl(), $mountPath, $source, true, [ 'delete' => $input->getOption('delete'), 'exclude' => $input->getOption('exclude'), 'include' => $input->getOption('include'), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/src/Command/Self/SelfInstallCommand.php new/platformsh-cli-3.41.1/src/Command/Self/SelfInstallCommand.php --- old/platformsh-cli-3.40.16/src/Command/Self/SelfInstallCommand.php 2019-05-18 21:59:27.000000000 +0200 +++ new/platformsh-cli-3.41.1/src/Command/Self/SelfInstallCommand.php 2019-05-29 23:19:27.000000000 +0200 @@ -334,8 +334,14 @@ } // If none of the files exist (yet), and we are on Bash, and the home - // directory is writable, then use ~/.bashrc. + // directory is writable, then use ~/.bashrc or ~/.bash_profile on + // OS X. if (is_writable($homeDir) && $shell === 'bash') { + if (OsUtil::isOsX()) { + $this->debug('OS X: defaulting to ~/.bash_profile'); + + return $homeDir . DIRECTORY_SEPARATOR . '.bash_profile'; + } $this->debug('Defaulting to ~/.bashrc'); return $homeDir . DIRECTORY_SEPARATOR . '.bashrc'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/src/Local/LocalApplication.php new/platformsh-cli-3.41.1/src/Local/LocalApplication.php --- old/platformsh-cli-3.40.16/src/Local/LocalApplication.php 2019-05-18 21:59:27.000000000 +0200 +++ new/platformsh-cli-3.41.1/src/Local/LocalApplication.php 2019-05-29 23:19:27.000000000 +0200 @@ -170,7 +170,11 @@ */ public function getSharedFileMounts() { - return $this->mount->getSharedFileMounts($this->getConfig()); + $config = $this->getConfig(); + + return !empty($config['mounts']) + ? $this->mount->getSharedFileMounts($config['mounts']) + : []; } /** diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/src/Model/SshDestination/App.php new/platformsh-cli-3.41.1/src/Model/SshDestination/App.php --- old/platformsh-cli-3.40.16/src/Model/SshDestination/App.php 1970-01-01 01:00:00.000000000 +0100 +++ new/platformsh-cli-3.41.1/src/Model/SshDestination/App.php 2019-05-29 23:19:27.000000000 +0200 @@ -0,0 +1,55 @@ +<?php + +namespace Platformsh\Cli\Model\SshDestination; + +use Platformsh\Cli\Model\AppConfig; +use Platformsh\Client\Model\Deployment\WebApp; +use Platformsh\Client\Model\Environment; + +class App implements SshDestinationInterface +{ + private $webApp; + private $environment; + + /** + * @param \Platformsh\Client\Model\Deployment\WebApp $webApp + * @param \Platformsh\Client\Model\Environment $environment + */ + public function __construct(WebApp $webApp, Environment $environment) { + $this->webApp = $webApp; + $this->environment = $environment; + } + + /** + * {@inheritdoc} + */ + public function getSshUrl() + { + return $this->environment->getSshUrl($this->webApp->name); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->webApp->name; + } + + /** + * {@inheritdoc} + */ + public function getType() + { + return 'app'; + } + + /** + * {@inheritdoc} + */ + public function getMounts() { + $config = AppConfig::fromWebApp($this->webApp)->getNormalized(); + + return !empty($config['mounts']) ? $config['mounts'] : []; + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/src/Model/SshDestination/SshDestinationInterface.php new/platformsh-cli-3.41.1/src/Model/SshDestination/SshDestinationInterface.php --- old/platformsh-cli-3.40.16/src/Model/SshDestination/SshDestinationInterface.php 1970-01-01 01:00:00.000000000 +0100 +++ new/platformsh-cli-3.41.1/src/Model/SshDestination/SshDestinationInterface.php 2019-05-29 23:19:27.000000000 +0200 @@ -0,0 +1,39 @@ +<?php + +namespace Platformsh\Cli\Model\SshDestination; + +/** + * Represents a resource that provides an SSH server. + */ +interface SshDestinationInterface +{ + /** + * Returns the destination's SSH URL. + * + * @return string + */ + public function getSshUrl(); + + /** + * Returns the destination's name (machine or human-readable). + * + * @return string + */ + public function getName(); + + /** + * Returns the destination type (a human-readable string). + * + * @return string + */ + public function getType(); + + /** + * Lists file mounts on the destination. + * + * @return array + * An associative array of mounts, taken from the configuration in the + * app config file (.platform.app.yaml). + */ + public function getMounts(); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/src/Model/SshDestination/Worker.php new/platformsh-cli-3.41.1/src/Model/SshDestination/Worker.php --- old/platformsh-cli-3.40.16/src/Model/SshDestination/Worker.php 1970-01-01 01:00:00.000000000 +0100 +++ new/platformsh-cli-3.41.1/src/Model/SshDestination/Worker.php 2019-05-29 23:19:27.000000000 +0200 @@ -0,0 +1,55 @@ +<?php + +namespace Platformsh\Cli\Model\SshDestination; + +use Platformsh\Cli\Model\AppConfig; +use Platformsh\Client\Model\Environment; +use Platformsh\Client\Model\Deployment\Worker as DeployedWorker; + +class Worker implements SshDestinationInterface +{ + private $worker; + private $environment; + + /** + * @param \Platformsh\Client\Model\Deployment\Worker $worker + * @param \Platformsh\Client\Model\Environment $environment + */ + public function __construct(DeployedWorker $worker, Environment $environment) { + $this->worker = $worker; + $this->environment = $environment; + } + + /** + * {@inheritdoc} + */ + public function getSshUrl() + { + return $this->environment->getWorkerSshUrl($this->worker); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->worker->name; + } + + /** + * {@inheritdoc} + */ + public function getType() + { + return 'worker'; + } + + /** + * {@inheritdoc} + */ + public function getMounts() { + $config = (new AppConfig($this->worker->getProperties()))->getNormalized(); + + return !empty($config['mounts']) ? $config['mounts'] : []; + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/src/Service/Api.php new/platformsh-cli-3.41.1/src/Service/Api.php --- old/platformsh-cli-3.40.16/src/Service/Api.php 2019-05-18 21:59:27.000000000 +0200 +++ new/platformsh-cli-3.41.1/src/Service/Api.php 2019-05-29 23:19:27.000000000 +0200 @@ -296,7 +296,9 @@ // separate cache. $projects = $this->getProjects($refresh); if (isset($projects[$id])) { - return $projects[$id]; + if ($host === null || stripos(parse_url($projects[$id]->getUri(), PHP_URL_HOST), $host) !== false) { + return $projects[$id]; + } } // Find the project directly. @@ -757,13 +759,13 @@ */ public function getCurrentDeployment(Environment $environment, $refresh = false) { - $cacheKey = implode(':', ['current-deployment', $environment->project, $environment->id]); + $cacheKey = implode(':', ['current-deployment', $environment->project, $environment->id, $environment->head_commit]); $data = $this->cache->fetch($cacheKey); if ($data === false || $refresh) { $deployment = $environment->getCurrentDeployment(); $data = $deployment->getData(); $data['_uri'] = $deployment->getUri(); - $this->cache->save($cacheKey, $data, $this->config->get('api.environments_ttl')); + $this->cache->save($cacheKey, $data); } else { $deployment = new EnvironmentDeployment($data, $data['_uri'], $this->getHttpClient(), true); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.40.16/src/Service/Mount.php new/platformsh-cli-3.41.1/src/Service/Mount.php --- old/platformsh-cli-3.40.16/src/Service/Mount.php 2019-05-18 21:59:27.000000000 +0200 +++ new/platformsh-cli-3.41.1/src/Service/Mount.php 2019-05-29 23:19:27.000000000 +0200 @@ -11,21 +11,20 @@ /** * Get a list of shared file mounts configured for an app. * - * @param array $appConfig The app configuration. + * @param array $mounts An associative array of mounts, taken from the app + * configuration. * * @return array * An array of shared file paths, keyed by the mount path. Leading and * trailing slashes are stripped. An empty shared path defaults to * 'files'. */ - public function getSharedFileMounts(array $appConfig) + public function getSharedFileMounts(array $mounts) { $sharedFileMounts = []; - if (!empty($appConfig['mounts'])) { - foreach ($this->normalizeMounts($appConfig['mounts']) as $path => $definition) { - if (isset($definition['source_path'])) { - $sharedFileMounts[$path] = $definition['source_path'] ?: 'files'; - } + foreach ($this->normalizeMounts($mounts) as $path => $definition) { + if (isset($definition['source_path'])) { + $sharedFileMounts[$path] = $definition['source_path'] ?: 'files'; } } @@ -35,6 +34,10 @@ /** * Normalize a list of mounts. * + * This ensures the mount path does not begin or end with a '/', and that + * the mount definition is in the newer structured format, with a 'source' + * and probably a 'source_path'. + * * @param array $mounts * * @return array @@ -50,22 +53,24 @@ } /** - * Validate and normalize a path to a mount. + * Checks that a given path matches a mount in the list. * - * @param string $inputPath + * @param string $path * @param array $mounts * + * @throws \InvalidArgumentException if the path does not match + * * @return string - * The normalized mount path. + * If the $path matches, the normalized path is returned. */ - public function validateMountPath($inputPath, array $mounts) + public function matchMountPath($path, array $mounts) { - $normalized = $this->normalizeRelativePath($inputPath); + $normalized = $this->normalizeRelativePath($path); if (isset($mounts[$normalized])) { return $normalized; } - throw new \InvalidArgumentException(sprintf('Mount not found: <error>%s</error>', $inputPath)); + throw new \InvalidArgumentException(sprintf('Mount not found: <error>%s</error>', $path)); } /** ++++++ platformsh-cli-vendor.tar.xz ++++++ ++++ 9957 lines of diff (skipped)
participants (1)
-
root