Hello community, here is the log from the commit of package platformsh-cli for openSUSE:Factory checked in at 2018-05-17 18:04:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/platformsh-cli (Old) and /work/SRC/openSUSE:Factory/.platformsh-cli.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "platformsh-cli" Thu May 17 18:04:52 2018 rev:48 rq:609929 version:3.33.0 Changes: -------- --- /work/SRC/openSUSE:Factory/platformsh-cli/platformsh-cli.changes 2018-05-16 11:41:57.283510257 +0200 +++ /work/SRC/openSUSE:Factory/.platformsh-cli.new/platformsh-cli.changes 2018-05-17 18:05:31.795635932 +0200 @@ -1,0 +2,12 @@ +Wed May 16 19:59:27 UTC 2018 - [email protected] + +- Update to version 3.33.0: + * Release v3.33.0 + * Add --sensitive option for project-level variables (#716) + * Add mount:size command (#713) + * Add a README warning about debug mode [skip changelog] + * Clear environment/project caches after a 403 error + * Increase prominence of warning in db:size (#712) + * Ignore automatic updates if the Phar is not writable + +------------------------------------------------------------------- Old: ---- platformsh-cli-3.32.5.tar.xz New: ---- platformsh-cli-3.33.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ platformsh-cli.spec ++++++ --- /var/tmp/diff_new_pack.bMfXOL/_old 2018-05-17 18:05:33.439575810 +0200 +++ /var/tmp/diff_new_pack.bMfXOL/_new 2018-05-17 18:05:33.439575810 +0200 @@ -17,7 +17,7 @@ Name: platformsh-cli -Version: 3.32.5 +Version: 3.33.0 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.bMfXOL/_old 2018-05-17 18:05:33.475574493 +0200 +++ /var/tmp/diff_new_pack.bMfXOL/_new 2018-05-17 18:05:33.479574347 +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.32.5</param> + <param name="revision">refs/tags/v3.33.0</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.bMfXOL/_old 2018-05-17 18:05:33.499573616 +0200 +++ /var/tmp/diff_new_pack.bMfXOL/_new 2018-05-17 18:05:33.499573616 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">git://github.com/platformsh/platformsh-cli.git</param> - <param name="changesrevision">273b8e90b72a182b76e46a7f720e45c9b87b68c5</param> + <param name="changesrevision">d74fec48620834ff1ce4ce028c90219b39a38eef</param> </service> </servicedata> ++++++ licenses.txt ++++++ --- /var/tmp/diff_new_pack.bMfXOL/_old 2018-05-17 18:05:33.539572153 +0200 +++ /var/tmp/diff_new_pack.bMfXOL/_new 2018-05-17 18:05:33.547571860 +0200 @@ -17,7 +17,7 @@ padraic/humbug_get_contents 1.1.2 BSD-3-Clause padraic/phar-updater v1.0.5 BSD-3-Clause paragonie/random_compat v2.0.11 MIT -platformsh/client v0.17.2 MIT +platformsh/client v0.19.0 MIT platformsh/console-form v0.0.20 MIT psr/container 1.0.0 MIT psr/log 1.0.2 MIT ++++++ platformsh-cli-3.32.5.tar.xz -> platformsh-cli-3.33.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.32.5/README.md new/platformsh-cli-3.33.0/README.md --- old/platformsh-cli-3.32.5/README.md 2018-05-14 18:26:16.000000000 +0200 +++ new/platformsh-cli-3.33.0/README.md 2018-05-16 18:47:49.000000000 +0200 @@ -130,6 +130,7 @@ mount mount:download Download files from a mount, using rsync mount:list (mounts) Get a list of mounts + mount:size Check the disk usage of mounts mount:upload Upload files to a mount, using rsync project project:clear-build-cache Clear a project's build cache @@ -248,7 +249,7 @@ Other customization is available via environment variables: -* `PLATFORMSH_CLI_DEBUG`: set to 1 to enable cURL debugging +* `PLATFORMSH_CLI_DEBUG`: set to 1 to enable cURL debugging. _Warning_: this will print all request information in the terminal, including sensitive access tokens. * `PLATFORMSH_CLI_DISABLE_CACHE`: set to 1 to disable caching * `PLATFORMSH_CLI_SESSION_ID`: change user session (default 'default') * `PLATFORMSH_CLI_TOKEN`: an API token. _Warning_: storing a secret in an environment variable can be insecure. It may be better to use `config.yaml` as above, depending on your system. The environment variable is preferable on CI systems like Jenkins and GitLab. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.32.5/composer.json new/platformsh-cli-3.33.0/composer.json --- old/platformsh-cli-3.32.5/composer.json 2018-05-14 18:26:16.000000000 +0200 +++ new/platformsh-cli-3.33.0/composer.json 2018-05-16 18:47:49.000000000 +0200 @@ -8,7 +8,7 @@ "guzzlehttp/guzzle": "^5.3", "guzzlehttp/ringphp": "^1.1", "platformsh/console-form": ">=0.0.20 <2.0", - "platformsh/client": ">=0.17.1 <2.0", + "platformsh/client": ">=0.19.0 <2.0", "symfony/console": "^3.0 !=3.2.5 !=3.2.6", "symfony/yaml": "^3.0 || ^2.6", "symfony/finder": "^3.0", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.32.5/composer.lock new/platformsh-cli-3.33.0/composer.lock --- old/platformsh-cli-3.32.5/composer.lock 2018-05-14 18:26:16.000000000 +0200 +++ new/platformsh-cli-3.33.0/composer.lock 2018-05-16 18:47:49.000000000 +0200 @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "a2e75cbf8fc0447fd95e5c91aa368330", + "content-hash": "74c0af5321e8db7fd50eadd0f54f1e74", "packages": [ { "name": "cocur/slugify", @@ -711,16 +711,16 @@ }, { "name": "platformsh/client", - "version": "v0.17.2", + "version": "v0.19.0", "source": { "type": "git", "url": "https://github.com/platformsh/platformsh-client-php.git", - "reference": "78f7b14818fe6e5c171855c217dfddf738d50302" + "reference": "e5baf70609b6fe47fac22e8f6cee364112d548f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/platformsh/platformsh-client-php/zipball/78f7b14818fe6e5c171855c217dfddf738d50302", - "reference": "78f7b14818fe6e5c171855c217dfddf738d50302", + "url": "https://api.github.com/repos/platformsh/platformsh-client-php/zipball/e5baf70609b6fe47fac22e8f6cee364112d548f0", + "reference": "e5baf70609b6fe47fac22e8f6cee364112d548f0", "shasum": "" }, "require": { @@ -756,7 +756,7 @@ } ], "description": "Platform.sh API client", - "time": "2018-03-22T15:23:59+00:00" + "time": "2018-05-16T13:05:28+00:00" }, { "name": "platformsh/console-form", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.32.5/config.yaml new/platformsh-cli-3.33.0/config.yaml --- old/platformsh-cli-3.32.5/config.yaml 2018-05-14 18:26:16.000000000 +0200 +++ new/platformsh-cli-3.33.0/config.yaml 2018-05-16 18:47:49.000000000 +0200 @@ -1,7 +1,7 @@ # Metadata about the CLI application itself. application: name: 'Platform.sh CLI' - version: '3.32.5' + version: '3.33.0' executable: 'platform' package_name: 'platformsh/cli' installer_url: 'https://platform.sh/cli/installer' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.32.5/dist/manifest.json new/platformsh-cli-3.33.0/dist/manifest.json --- old/platformsh-cli-3.32.5/dist/manifest.json 2018-05-14 18:26:16.000000000 +0200 +++ new/platformsh-cli-3.33.0/dist/manifest.json 2018-05-16 18:47:49.000000000 +0200 @@ -1,10 +1,10 @@ [ { "name": "platform.phar", - "sha1": "cb1253f9a1c0be7c78462d32611c5f6d11dda50e", - "sha256": "220684dde9f5236d2c9b16982c8bc4d5a8211d9d1cd30e1e6474312136575e85", - "url": "https://github.com/platformsh/platformsh-cli/releases/download/v3.32.5/platform.phar", - "version": "3.32.5", + "sha1": "5475eaa9a92eba96ff89982c4c3d7e0d67c486a0", + "sha256": "1b1cd2ce4bb721c000f6549f37d9bc981be0d616b8e91d0390d74993251c0f3f", + "url": "https://github.com/platformsh/platformsh-cli/releases/download/v3.33.0/platform.phar", + "version": "3.33.0", "php": { "min": "5.5.9" }, @@ -127,6 +127,11 @@ "notes": "* Increase the default interval between updates checks, from 1 day to 7 days.\n* Fix formatting for activity descriptions that contain a `/` character.\n* In the `project:set-remote` command, do not error out if the \"current\" project\n does not exist.\n* Minor performance improvement to `user` commands when looking up existing\n users.", "show from": "3.32.3", "hide from": "3.32.4" + }, + { + "notes": "* Add `mount:size` command to find the disk usage of writable mounts.\n* Add `--sensitive` option for project-level variables (affects commands:\n `variable:create`, `variable:update`, and `variable:list`).\n* Clear environment/project caches after a 403 error.\n* Increase prominence of warning in `db:size` command.\n* Skip the automatic updates check if the Phar file is not writable.", + "show from": "3.32.0", + "hide from": "3.33.0" } ] } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.32.5/src/Application.php new/platformsh-cli-3.33.0/src/Application.php --- old/platformsh-cli-3.32.5/src/Application.php 2018-05-14 18:26:16.000000000 +0200 +++ new/platformsh-cli-3.33.0/src/Application.php 2018-05-16 18:47:49.000000000 +0200 @@ -144,6 +144,7 @@ $commands[] = new Command\Local\LocalDirCommand(); $commands[] = new Command\Mount\MountListCommand(); $commands[] = new Command\Mount\MountDownloadCommand(); + $commands[] = new Command\Mount\MountSizeCommand(); $commands[] = new Command\Mount\MountUploadCommand(); $commands[] = new Command\Project\ProjectClearBuildCacheCommand(); $commands[] = new Command\Project\ProjectCurlCommand(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.32.5/src/Command/CommandBase.php new/platformsh-cli-3.33.0/src/Command/CommandBase.php --- old/platformsh-cli-3.32.5/src/Command/CommandBase.php 2018-05-14 18:26:16.000000000 +0200 +++ new/platformsh-cli-3.33.0/src/Command/CommandBase.php 2018-05-16 18:47:49.000000000 +0200 @@ -244,6 +244,11 @@ return; } + // Check if the file is writable. + if (!is_writable($pharFilename)) { + return; + } + // Check if updates are configured. $config = $this->config(); if (!$config->get('updates.check')) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.32.5/src/Command/Db/DbSizeCommand.php new/platformsh-cli-3.33.0/src/Command/Db/DbSizeCommand.php --- old/platformsh-cli-3.32.5/src/Command/Db/DbSizeCommand.php 2018-05-14 18:26:16.000000000 +0200 +++ new/platformsh-cli-3.33.0/src/Command/Db/DbSizeCommand.php 2018-05-16 18:47:49.000000000 +0200 @@ -20,7 +20,7 @@ $this->setName('db:size') ->setDescription('Estimate the disk usage of a database') ->setHelp( - "This command provides an estimate of the database's disk usage. It is not guaranteed to be reliable." + "This is an estimate of the database disk usage. It does not represent its real size on disk." ); $this->addProjectOption()->addEnvironmentOption()->addAppOption(); Relationships::configureInput($this->getDefinition()); @@ -75,14 +75,13 @@ $allocatedDisk = false; } - $this->stdErr->write('Querying database <comment>' . $dbServiceName . '</comment> to estimate disk usage. '); - $this->stdErr->writeln('This might take a while.'); - /** @var Shell $shell */ $shell = $this->getService('shell'); /** @var \Platformsh\Cli\Service\Ssh $ssh */ $ssh = $this->getService('ssh'); + $this->stdErr->writeln('Checking database <comment>' . $dbServiceName . '</comment>...'); + $command = ['ssh']; $command = array_merge($command, $ssh->getSshArgs()); $command[] = $sshUrl; @@ -120,6 +119,10 @@ $table->renderSimple($values, $propertyNames); + $this->stdErr->writeln(''); + $this->stdErr->writeln('<options=bold;fg=yellow>Warning</>'); + $this->stdErr->writeln("This is an estimate of the database's disk usage. It does not represent its real size on disk."); + return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.32.5/src/Command/Mount/MountSizeCommand.php new/platformsh-cli-3.33.0/src/Command/Mount/MountSizeCommand.php --- old/platformsh-cli-3.32.5/src/Command/Mount/MountSizeCommand.php 1970-01-01 01:00:00.000000000 +0100 +++ new/platformsh-cli-3.33.0/src/Command/Mount/MountSizeCommand.php 2018-05-16 18:47:49.000000000 +0200 @@ -0,0 +1,195 @@ +<?php + +namespace Platformsh\Cli\Command\Mount; + +use Platformsh\Cli\Service\Ssh; +use Platformsh\Cli\Service\Table; +use Symfony\Component\Console\Helper\Helper; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +class MountSizeCommand extends MountCommandBase +{ + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('mount:size') + ->setDescription('Check the disk usage of mounts') + ->addOption('bytes', 'B', InputOption::VALUE_NONE, 'Show sizes in bytes'); + Table::configureInput($this->getDefinition()); + Ssh::configureInput($this->getDefinition()); + $this->addProjectOption(); + $this->addEnvironmentOption(); + $this->addAppOption(); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->validateInput($input); + + $appName = $this->selectApp($input); + + $appConfig = $this->getAppConfig($appName); + if (empty($appConfig['mounts'])) { + $this->stdErr->writeln(sprintf('The app "%s" doesn\'t define any mounts.', $appConfig['name'])); + + return 1; + } + + $this->stdErr->writeln(sprintf('Checking disk usage for all mounts of the application <info>%s</info>...', $appName)); + + // 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) { + $mountPaths[] = trim(trim($mountPath), '/'); + } + + // Build a list of multiple commands that will be run over the same SSH + // connection: + // 1. Get the application directory (by reading the PLATFORM_APP_DIR + // environment variable). + // 2. Run the 'df' command to find filesystem statistics for the + // mounts. + // 3. Run a 'du' command on each of the mounted paths, to find their + // individual sizes. + $appDirVar = $this->config()->get('service.env_prefix') . 'APP_DIR'; + $commands = []; + $commands[] = 'echo "$' . $appDirVar . '"'; + $commands[] = 'echo'; + $commands[] = 'df -P -B1 -a -x squashfs -x tmpfs -x sysfs -x proc -x devpts'; + $commands[] = 'echo'; + $commands[] = 'cd "$' . $appDirVar . '"'; + foreach ($mountPaths as $mountPath) { + $commands[] = 'du --block-size=1 -s ' . escapeshellarg($mountPath); + } + $command = 'set -e; ' . implode('; ', $commands); + + // Connect to the application via SSH and run the commands. + $sshArgs = [ + 'ssh', + $this->getSelectedEnvironment()->getSshUrl($appName), + ]; + /** @var \Platformsh\Cli\Service\Ssh $ssh */ + $ssh = $this->getService('ssh'); + $sshArgs = array_merge($sshArgs, $ssh->getSshArgs()); + /** @var \Platformsh\Cli\Service\Shell $shell */ + $shell = $this->getService('shell'); + $result = $shell->execute(array_merge($sshArgs, [$command]), null, true); + + // Separate the commands' output. + list($appDir, $dfOutput, $duOutput) = explode("\n\n", $result, 3); + + // Parse the output of 'df', building a list of results. + $results = []; + foreach (explode("\n", $dfOutput) as $i => $line) { + if ($i === 0) { + continue; + } + $path = $this->getDfColumn($line, 'path'); + if (strpos($path, $appDir . '/') !== 0) { + continue; + } + $mountPath = ltrim(substr($path, strlen($appDir)), '/'); + if (!in_array($mountPath, $mountPaths)) { + continue; + } + $filesystem = $this->getDfColumn($line, 'filesystem'); + if (isset($results[$filesystem])) { + $results[$filesystem]['mounts'][] = $mountPath; + continue; + } + $available = $this->getDfColumn($line, 'available'); + $used = $this->getDfColumn($line, 'used'); + $results[$filesystem] = [ + 'total' => $this->getDfColumn($line, 'total'), + 'used' => $used, + 'available' => $available, + 'mounts' => [$mountPath], + 'percent_used' => $used / $available * 100, + ]; + } + + // Parse the 'du' output. + $mountSizes = []; + $duOutputSplit = explode("\n", $duOutput, count($mountPaths)); + foreach ($mountPaths as $i => $mountPath) { + if (!isset($duOutputSplit[$i])) { + throw new \RuntimeException("Failed to find row $i of 'du' command output: \n" . $duOutput); + } + list($mountSizes[$mountPath],) = explode("\t", $duOutputSplit[$i], 2); + } + + /** @var \Platformsh\Cli\Service\Table $table */ + $table = $this->getService('table'); + + $header = ['Mount(s)', 'Size(s)', 'Disk', 'Used', 'Available', 'Capacity']; + + $showInBytes = $input->getOption('bytes'); + + $rows = []; + foreach ($results as $info) { + $row = []; + $row[] = implode("\n", $info['mounts']); + $mountUsage = []; + foreach ($info['mounts'] as $mountPath) { + $mountUsage[] = $mountSizes[$mountPath]; + } + if ($showInBytes) { + $row[] = implode("\n", $mountUsage); + $row[] = $info['total']; + $row[] = $info['used']; + $row[] = $info['available']; + } else { + $row[] = implode("\n", array_map([Helper::class, 'formatMemory'], $mountUsage)); + $row[] = Helper::formatMemory($info['total']); + $row[] = Helper::formatMemory($info['used']); + $row[] = Helper::formatMemory($info['available']); + } + $row[] = round($info['percent_used'], 1) . '%'; + $rows[] = $row; + } + + $table->render($rows, $header); + + return 0; + } + + /** + * Get a column from a line of df output. + * + * Unfortunately there doesn't seem to be a more reliable way to parse df + * output than by regular expression. + * + * @param string $line + * @param string $columnName + * + * @return string + */ + private function getDfColumn($line, $columnName) + { + $columnPatterns = [ + 'filesystem' => '#^(.+?)(\s+[0-9])#', + 'total' => '#([0-9]+)\s+[0-9]+\s+[0-9]+\s+[0-9]+%\s+#', + 'used' => '#([0-9]+)\s+[0-9]+\s+[0-9]+%\s+#', + 'available' => '#([0-9]+)\s+[0-9]+%\s+#', + 'path' => '#%\s+(/.+)$#', + ]; + if (!isset($columnPatterns[$columnName])) { + throw new \InvalidArgumentException("Invalid df column: $columnName"); + } + if (!preg_match($columnPatterns[$columnName], $line, $matches)) { + throw new \RuntimeException("Failed to find column '$columnName' in df line: \n$line"); + } + + return trim($matches[1]); + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.32.5/src/Command/Variable/VariableCommandBase.php new/platformsh-cli-3.33.0/src/Command/Variable/VariableCommandBase.php --- old/platformsh-cli-3.32.5/src/Command/Variable/VariableCommandBase.php 2018-05-14 18:26:16.000000000 +0200 +++ new/platformsh-cli-3.33.0/src/Command/Variable/VariableCommandBase.php 2018-05-16 18:47:49.000000000 +0200 @@ -200,9 +200,6 @@ 'default' => false, ]); $fields['is_sensitive'] = new BooleanField('Sensitive', [ - 'conditions' => [ - 'level' => self::LEVEL_ENVIRONMENT, - ], 'description' => 'Whether the variable is sensitive', 'questionLine' => 'Is the value sensitive?', 'default' => false, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.32.5/src/Command/Variable/VariableListCommand.php new/platformsh-cli-3.33.0/src/Command/Variable/VariableListCommand.php --- old/platformsh-cli-3.32.5/src/Command/Variable/VariableListCommand.php 2018-05-14 18:26:16.000000000 +0200 +++ new/platformsh-cli-3.33.0/src/Command/Variable/VariableListCommand.php 2018-05-16 18:47:49.000000000 +0200 @@ -77,8 +77,8 @@ $row[] = new AdaptiveTableCell($this->getVariableLevel($variable), ['wrap' => false]); // Handle sensitive variables' value (it isn't exposed in the API). - if ($variable instanceof EnvironmentLevelVariable && !$variable->hasProperty('value') && $variable->is_sensitive) { - $row[] = '[sensitive]'; + if (!$variable->hasProperty('value', false) && $variable->is_sensitive) { + $row[] = '<fg=yellow>[Hidden: sensitive value]</>'; } else { $row[] = wordwrap($variable->value, 40, "\n", true); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.32.5/src/Service/Api.php new/platformsh-cli-3.33.0/src/Service/Api.php --- old/platformsh-cli-3.32.5/src/Service/Api.php 2018-05-14 18:26:16.000000000 +0200 +++ new/platformsh-cli-3.33.0/src/Service/Api.php 2018-05-16 18:47:49.000000000 +0200 @@ -4,6 +4,7 @@ use Doctrine\Common\Cache\CacheProvider; use GuzzleHttp\ClientInterface; +use GuzzleHttp\Event\ErrorEvent; use Platformsh\Cli\Event\EnvironmentsChangedEvent; use Platformsh\Cli\Exception\ApiFeatureMissingException; use Platformsh\Cli\Session\KeychainStorage; @@ -210,6 +211,12 @@ self::$client = new PlatformClient($connector); + $connector->getClient()->getEmitter()->on('error', function (ErrorEvent $event) { + if ($event->getResponse() && $event->getResponse()->getStatusCode() === 403) { + $this->on403($event); + } + }); + if ($autoLogin && !$connector->isLoggedIn()) { $this->dispatcher->dispatch('login_required'); } @@ -887,4 +894,25 @@ return $environment->operationAvailable($op); } + + /** + * React on an API 403 request. + * + * @param \GuzzleHttp\Event\ErrorEvent $event + */ + private function on403(ErrorEvent $event) + { + $url = $event->getRequest()->getUrl(); + $path = parse_url($url, PHP_URL_PATH); + if ($path && strpos($path, '/api/projects/') === 0) { + // Clear the environments cache for environment request errors. + if (preg_match('#^/api/projects/([^/]+?)/environments/#', $path, $matches)) { + $this->clearEnvironmentsCache($matches[1]); + } + // Clear the projects cache for other project request errors. + if (preg_match('#^/api/projects/([^/]+?)[/$]/#', $path, $matches)) { + $this->clearProjectsCache(); + } + } + } } ++++++ platformsh-cli-vendor.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/autoload.php new/vendor/autoload.php --- old/vendor/autoload.php 2018-05-14 23:53:05.240987472 +0200 +++ new/vendor/autoload.php 2018-05-16 21:59:31.431404042 +0200 @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitbbf089209b59236a9485072bbec22b9d::getLoader(); +return ComposerAutoloaderInit223df01762ee6625803aefa4e7d54ccb::getLoader(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/composer/autoload_real.php new/vendor/composer/autoload_real.php --- old/vendor/composer/autoload_real.php 2018-05-14 23:53:05.240987472 +0200 +++ new/vendor/composer/autoload_real.php 2018-05-16 21:59:31.431404042 +0200 @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitbbf089209b59236a9485072bbec22b9d +class ComposerAutoloaderInit223df01762ee6625803aefa4e7d54ccb { private static $loader; @@ -19,15 +19,15 @@ return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitbbf089209b59236a9485072bbec22b9d', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit223df01762ee6625803aefa4e7d54ccb', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInitbbf089209b59236a9485072bbec22b9d', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit223df01762ee6625803aefa4e7d54ccb', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitbbf089209b59236a9485072bbec22b9d::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit223df01762ee6625803aefa4e7d54ccb::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,19 +48,19 @@ $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInitbbf089209b59236a9485072bbec22b9d::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit223df01762ee6625803aefa4e7d54ccb::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequirebbf089209b59236a9485072bbec22b9d($fileIdentifier, $file); + composerRequire223df01762ee6625803aefa4e7d54ccb($fileIdentifier, $file); } return $loader; } } -function composerRequirebbf089209b59236a9485072bbec22b9d($fileIdentifier, $file) +function composerRequire223df01762ee6625803aefa4e7d54ccb($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/composer/autoload_static.php new/vendor/composer/autoload_static.php --- old/vendor/composer/autoload_static.php 2018-05-14 23:53:05.240987472 +0200 +++ new/vendor/composer/autoload_static.php 2018-05-16 21:59:31.431404042 +0200 @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitbbf089209b59236a9485072bbec22b9d +class ComposerStaticInit223df01762ee6625803aefa4e7d54ccb { public static $files = array ( '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', @@ -195,9 +195,9 @@ public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitbbf089209b59236a9485072bbec22b9d::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitbbf089209b59236a9485072bbec22b9d::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitbbf089209b59236a9485072bbec22b9d::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit223df01762ee6625803aefa4e7d54ccb::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit223df01762ee6625803aefa4e7d54ccb::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit223df01762ee6625803aefa4e7d54ccb::$classMap; }, null, ClassLoader::class); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/composer/installed.json new/vendor/composer/installed.json --- old/vendor/composer/installed.json 2018-05-14 23:53:04.628980762 +0200 +++ new/vendor/composer/installed.json 2018-05-16 21:59:30.843398848 +0200 @@ -778,17 +778,17 @@ }, { "name": "platformsh/client", - "version": "v0.17.2", - "version_normalized": "0.17.2.0", + "version": "v0.19.0", + "version_normalized": "0.19.0.0", "source": { "type": "git", "url": "https://github.com/platformsh/platformsh-client-php.git", - "reference": "78f7b14818fe6e5c171855c217dfddf738d50302" + "reference": "e5baf70609b6fe47fac22e8f6cee364112d548f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/platformsh/platformsh-client-php/zipball/78f7b14818fe6e5c171855c217dfddf738d50302", - "reference": "78f7b14818fe6e5c171855c217dfddf738d50302", + "url": "https://api.github.com/repos/platformsh/platformsh-client-php/zipball/e5baf70609b6fe47fac22e8f6cee364112d548f0", + "reference": "e5baf70609b6fe47fac22e8f6cee364112d548f0", "shasum": "" }, "require": { @@ -801,7 +801,7 @@ "require-dev": { "phpunit/phpunit": "~4.5" }, - "time": "2018-03-22T15:23:59+00:00", + "time": "2018-05-16T13:05:28+00:00", "type": "library", "extra": { "patches": { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/client/.travis.yml new/vendor/platformsh/client/.travis.yml --- old/vendor/platformsh/client/.travis.yml 2018-03-22 16:23:59.000000000 +0100 +++ new/vendor/platformsh/client/.travis.yml 2018-05-16 15:05:28.000000000 +0200 @@ -6,7 +6,6 @@ - 7.0 - 5.6 - 5.5 - - hhvm cache: directories: - $HOME/.composer/cache diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/client/src/Model/Environment.php new/vendor/platformsh/client/src/Model/Environment.php --- old/vendor/platformsh/client/src/Model/Environment.php 2018-03-22 16:23:59.000000000 +0100 +++ new/vendor/platformsh/client/src/Model/Environment.php 2018-05-16 15:05:28.000000000 +0200 @@ -306,19 +306,27 @@ /** * Synchronize an environment with its parent. * - * @param bool $code - * @param bool $data + * @param bool $code Synchronize code. + * @param bool $data Synchronize data. + * @param bool $rebase Synchronize code by rebasing instead of merging. * * @throws \InvalidArgumentException * * @return Activity */ - public function synchronize($data = false, $code = false) + public function synchronize($data = false, $code = false, $rebase = false) { if (!$data && !$code) { throw new \InvalidArgumentException('Nothing to synchronize: you must specify $data or $code'); } - $body = ['synchronize_data' => $data, 'synchronize_code' => $code]; + $body = [ + 'synchronize_data' => $data, + 'synchronize_code' => $code, + ]; + if ($rebase) { + // @todo always add this (when the rebase option is GA) + $body['rebase'] = $rebase; + } return $this->runLongOperation('synchronize', 'post', $body); } @@ -389,16 +397,26 @@ * @param mixed $value * @param bool $json * @param bool $enabled + * @param bool $sensitive * * @return Result */ - public function setVariable($name, $value, $json = false, $enabled = true) + public function setVariable( + $name, + $value, + $json = false, + $enabled = true, + $sensitive = false + ) { if (!is_scalar($value)) { $value = json_encode($value); $json = true; } $values = ['value' => $value, 'is_json' => $json, 'is_enabled' => $enabled]; + if ($sensitive) { + $values['is_sensitive'] = $sensitive; + } $existing = $this->getVariable($name); if ($existing) { return $existing->update($values); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/client/src/Model/Project.php new/vendor/platformsh/client/src/Model/Project.php --- old/vendor/platformsh/client/src/Model/Project.php 2018-03-22 16:23:59.000000000 +0100 +++ new/vendor/platformsh/client/src/Model/Project.php 2018-05-16 15:05:28.000000000 +0200 @@ -309,16 +309,24 @@ * @param mixed $value * The value of the variable to set. If non-scalar it will be JSON-encoded automatically. * @param bool $json - * True if this value is an encoded JSON value. false if it's a primitive. + * Whether this variable's value is JSON-encoded. * @param bool $visibleBuild - * True if this variable should be exposed during the build phase, false otherwise. + * Whether this this variable should be exposed during the build phase. * @param bool $visibleRuntime - * True if this variable should be exposed during deploy and runtime, false otherwise. + * Whether this variable should be exposed during deploy and runtime. + * @param bool $sensitive + * Whether this variable's value should be readable via the API. * * @return Result */ - public function setVariable($name, $value, $json = false, $visibleBuild = true, $visibleRuntime = true) - { + public function setVariable( + $name, + $value, + $json = false, + $visibleBuild = true, + $visibleRuntime = true, + $sensitive = false + ) { // If $value isn't a scalar, assume it's supposed to be JSON. if (!is_scalar($value)) { $value = json_encode($value); @@ -329,6 +337,9 @@ 'is_json' => $json, 'visible_build' => $visibleBuild, 'visible_runtime' => $visibleRuntime]; + if ($sensitive) { + $values['is_sensitive'] = $sensitive; + } $existing = $this->getVariable($name); if ($existing) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/client/src/Model/ProjectLevelVariable.php new/vendor/platformsh/client/src/Model/ProjectLevelVariable.php --- old/vendor/platformsh/client/src/Model/ProjectLevelVariable.php 2018-03-22 16:23:59.000000000 +0100 +++ new/vendor/platformsh/client/src/Model/ProjectLevelVariable.php 2018-05-16 15:05:28.000000000 +0200 @@ -12,9 +12,12 @@ * @property-read string $name * The name of the variable. * @property-read string $value - * The value of the variable. + * The value of the variable. This is not readable if $is_sensitive is true. * @property-read bool $is_json * Whether the variable's value is a JSON string. + * @property-read bool $is_sensitive + * Whether the variable is sensitive. If so, its value will not be returned + * in the API. * @property-read bool $visible_build * Whether the variable should be visible at build time. * @property-read bool $visible_runtime diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/platformsh/client/src/Model/Variable.php new/vendor/platformsh/client/src/Model/Variable.php --- old/vendor/platformsh/client/src/Model/Variable.php 2018-03-22 16:23:59.000000000 +0100 +++ new/vendor/platformsh/client/src/Model/Variable.php 2018-05-16 15:05:28.000000000 +0200 @@ -14,10 +14,10 @@ * @property-read string $name * The name of the variable. * @property-read string $value - * The value of the variable. + * The value of the variable. This is not readable if $is_sensitive is true. * @property-read bool $is_sensitive - * Whether the variable is sensitive. If so, it will not be copied to child - * environments, and its value will not be returned in the API. + * Whether the variable is sensitive. If so, its value will not be returned + * in the API. * @property-read bool $is_enabled * Whether the variable is enabled. * @property-read bool $is_json
