Skip to content

Commit

Permalink
Adds domain purge command
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius committed Mar 21, 2020
1 parent e66dbe3 commit ddf5f4e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/Commands/DomainCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,35 @@ public function domainMove($uuid, $domain, $environmentFrom, $environmentTo)
$this->waitForNotification($addResponse);
}
}

/**
* Clears varnish cache for a specific domain.
*
* @param string $uuid
*
* @command domain:purge
*/
public function domainPurge($uuid, $environment, $domain = null)
{
if ($environment->name === 'prod' &&
!$this->confirm("Are you sure you want to purge varnish on the production environment?")) {
return;
}

$domainAdapter = new Domains($this->cloudapi);

if (null === $domain) {
$domains = $domainAdapter->getAll($environment->uuid);
$domainNames = array_map(function ($domain) {
$this->say(sprintf('Purging domain: %s', $domain->hostname));
return $domain->hostname;
}, $domains->getArrayCopy());
} else {
$this->say(sprintf('Purging domain: %s', $domain));
$domainNames = [$domain];
}

$response = $domainAdapter->purge($environment->uuid, $domainNames);
$this->waitForNotification($response);
}
}

0 comments on commit ddf5f4e

Please sign in to comment.