Skip to content

Commit 37f38a9

Browse files
committed
fix: add errors if trying to interact with databases on a private server
1 parent 83f6c87 commit 37f38a9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Command/Database/CreateDatabaseCommand.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Ymir\Cli\Command\Database;
1515

16+
use Symfony\Component\Console\Exception\RuntimeException;
1617
use Symfony\Component\Console\Input\InputArgument;
1718
use Symfony\Component\Console\Input\InputInterface;
1819
use Symfony\Component\Console\Input\InputOption;
@@ -45,6 +46,11 @@ protected function configure()
4546
protected function perform(InputInterface $input, OutputInterface $output)
4647
{
4748
$databaseServer = $this->determineDatabaseServer('On which database server would you like to create the new database?', $input, $output);
49+
50+
if (!$databaseServer['publicly_accessible']) {
51+
throw new RuntimeException('Database on private database servers need to be manually created.');
52+
}
53+
4854
$name = $this->getStringArgument($input, 'name');
4955

5056
if (empty($name)) {

src/Command/Database/ListDatabasesCommand.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Ymir\Cli\Command\Database;
1515

16+
use Symfony\Component\Console\Exception\RuntimeException;
1617
use Symfony\Component\Console\Input\InputArgument;
1718
use Symfony\Component\Console\Input\InputInterface;
1819
use Ymir\Cli\Console\OutputInterface;
@@ -42,9 +43,15 @@ protected function configure()
4243
*/
4344
protected function perform(InputInterface $input, OutputInterface $output)
4445
{
46+
$databaseServer = $this->determineDatabaseServer('Which database server would you like to list databases from', $input, $output);
47+
48+
if (!$databaseServer['publicly_accessible']) {
49+
throw new RuntimeException('Database on private database servers cannot be listed.');
50+
}
51+
4552
$output->table(
4653
['Name'],
47-
$this->apiClient->getDatabases($this->determineDatabaseServer('Which database server would you like to list databases from', $input, $output)['id'])->map(function (string $name) {
54+
$this->apiClient->getDatabases($databaseServer['id'])->map(function (string $name) {
4855
return [$name];
4956
})->all()
5057
);

0 commit comments

Comments
 (0)