diff --git a/src/Commands/Branch/ListCommand.php b/src/Commands/Branch/ListCommand.php index 85e445f00..fe5e5301f 100644 --- a/src/Commands/Branch/ListCommand.php +++ b/src/Commands/Branch/ListCommand.php @@ -7,6 +7,7 @@ use Pantheon\Terminus\Commands\StructuredListTrait; use Pantheon\Terminus\Site\SiteAwareInterface; use Pantheon\Terminus\Site\SiteAwareTrait; +use Pantheon\Terminus\Exceptions\TerminusIcrSiteException; /** * Class ListCommand @@ -37,6 +38,12 @@ class ListCommand extends TerminusCommand implements SiteAwareInterface */ public function listBranches($site_id) { - return $this->getRowsOfFields($this->getSiteById($site_id)->getBranches()); + try { + return $this->getRowsOfFields($this->getSiteById($site_id)->getBranches()); + } catch (TerminusIcrSiteException $e) { + $this->log()->notice("This is an ICR site, branches are managed in the external VCS."); + $this->log()->debug($e->getMessage()); + return; + } } } diff --git a/src/Commands/Connection/SetCommand.php b/src/Commands/Connection/SetCommand.php index 8eed56254..a81c833d7 100644 --- a/src/Commands/Connection/SetCommand.php +++ b/src/Commands/Connection/SetCommand.php @@ -7,6 +7,7 @@ use Pantheon\Terminus\Site\SiteAwareInterface; use Pantheon\Terminus\Site\SiteAwareTrait; use Pantheon\Terminus\Exceptions\TerminusException; +use Pantheon\Terminus\Exceptions\TerminusIcrSiteException; /** * Class SetCommand. @@ -64,6 +65,10 @@ public function connectionSet($site_env, $mode) try { $mode = strtolower($mode ?? ''); $workflow = $env->changeConnectionMode($mode); + } catch (TerminusIcrSiteException $e) { + $this->log()->debug($e->getMessage()); + $this->log()->notice("This is an ICR site, connection mode switching is not currently supported."); + return; } catch (TerminusException $e) { $message = $e->getMessage(); if (strpos($message, $mode) !== false) { diff --git a/src/Exceptions/TerminusIcrSiteException.php b/src/Exceptions/TerminusIcrSiteException.php new file mode 100644 index 000000000..5b2a8dd09 --- /dev/null +++ b/src/Exceptions/TerminusIcrSiteException.php @@ -0,0 +1,11 @@ + $exception->getMessage()] ); } else { - if (preg_match('/[2,4]0\d/', $response->getStatusCode())) { - // Do not retry on 20x and 40x responses. + if (preg_match('/[2,4]0\d/', $response->getStatusCode()) || $response->getStatusCode() == 410) { + // Do not retry on 20x, 40x or 410 responses. return false; } @@ -427,6 +428,11 @@ public function request($path, array $options = []): RequestOperationResult $this->logger->debug($jsonException->getMessage()); } + if ($response->getStatusCode() == 410 && $body == "icr_site") { + // This request is expected to fail for an ICR site, throw exception that will be catched down the road. + throw new TerminusIcrSiteException("This is an ICR site."); + } + return new RequestOperationResult([ 'data' => $body, 'headers' => $response->getHeaders(),