Misc fixes, templates
This commit is contained in:
parent
61f4f767c6
commit
df3e1211af
@ -2,6 +2,7 @@
|
|||||||
"$type": "service",
|
"$type": "service",
|
||||||
"name": "mailhog",
|
"name": "mailhog",
|
||||||
"description": "SMTP server that holds e-mail for debugging",
|
"description": "SMTP server that holds e-mail for debugging",
|
||||||
|
"info": "Mailhog accepts e-mails from any configured app over SMTP for use during development. Received messages can be displayed in the web interface.",
|
||||||
"tags": [ "app", "mail", "smtp" ],
|
"tags": [ "app", "mail", "smtp" ],
|
||||||
"author": null,
|
"author": null,
|
||||||
"image": "mailhog/mailhog",
|
"image": "mailhog/mailhog",
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
"$type": "service",
|
"$type": "service",
|
||||||
"name": "mariadb",
|
"name": "mariadb",
|
||||||
"description": "MariaDB RDBMS (MySQL fork)",
|
"description": "MariaDB RDBMS (MySQL fork)",
|
||||||
|
"info": "MariaDB is a mostly MySQL compatible relational database server.",
|
||||||
"help": "Default credentials are root/toor",
|
"help": "Default credentials are root/toor",
|
||||||
"tags": [ "rdbms", "mysql" ],
|
"tags": [ "rdbms", "mysql" ],
|
||||||
"author": null,
|
"author": null,
|
||||||
@ -16,17 +17,17 @@
|
|||||||
{ "path": "/data", "hint": "data" }
|
{ "path": "/data", "hint": "data" }
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"mongosh": {
|
"shell": {
|
||||||
"info": "Open the mongo shell",
|
"info": "Open the MariaDB shell",
|
||||||
"execute": "mongosh"
|
"execute": [ "mysql", "-uroot", "-p${MARIADB_ROOT_PASSWORD}" ]
|
||||||
},
|
},
|
||||||
"export": {
|
"export": {
|
||||||
"info": "Export the database",
|
"info": "Export the database",
|
||||||
"execute": "mysqldump "
|
"execute": "mysqldump -uroot -p${MARIADB_ROOT_PASSWORD} --all-databases"
|
||||||
},
|
},
|
||||||
"import": {
|
"import": {
|
||||||
"info": "Import the database",
|
"info": "Import the database",
|
||||||
"execute": "mongoimport"
|
"execute": "mysql -uroot -p${MARIADB_ROOT_PASSWORD}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"shell": {
|
"shell": {
|
||||||
"info": "Open the mongo shell",
|
"info": "Open the mongo shell",
|
||||||
"execute": "mongosh"
|
"execute": "mongosh",
|
||||||
|
"arguments": [ "-u", "root", "-p", "toor" ]
|
||||||
},
|
},
|
||||||
"export": {
|
"export": {
|
||||||
"info": "Export the database",
|
"info": "Export the database",
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"shell": {
|
"shell": {
|
||||||
"info": "Open the mongo shell",
|
"info": "Open the MySQL shell",
|
||||||
"execute": "mysql -uroot -p%{MARIADB_ROOT_PASSWORD}"
|
"execute": "mysql -uroot -p%{MARIADB_ROOT_PASSWORD}"
|
||||||
},
|
},
|
||||||
"export": {
|
"export": {
|
||||||
|
@ -41,12 +41,16 @@ class ExecCommand extends Command
|
|||||||
return self::SUCCESS;
|
return self::SUCCESS;
|
||||||
} elseif ($input->getOption("script")) {
|
} elseif ($input->getOption("script")) {
|
||||||
$script = $serviceInfo['scripts'][$command]['execute']??null;
|
$script = $serviceInfo['scripts'][$command]['execute']??null;
|
||||||
|
$scriptArgs = $serviceInfo['scripts'][$command]['arguments']??null;
|
||||||
if (!$script) {
|
if (!$script) {
|
||||||
$output->writeln("<error>No such script</>");
|
$output->writeln("<error>No such script</>");
|
||||||
return self::FAILURE;
|
return self::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmdl = [ is_array($script)?join("; ", $script):$script ];
|
if ($scriptArgs)
|
||||||
|
$cmdl = [ $script, ...$scriptArgs ]; // is_array($script)?join("; ", $script):$script ];
|
||||||
|
else
|
||||||
|
$cmdl = $script;
|
||||||
$containerManager->execute($serviceInfo, $instanceName, $cmdl);
|
$containerManager->execute($serviceInfo, $instanceName, $cmdl);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -17,6 +17,7 @@ class FindCommand extends Command
|
|||||||
$this->addArgument("service", InputArgument::OPTIONAL, "Search query");
|
$this->addArgument("service", InputArgument::OPTIONAL, "Search query");
|
||||||
$this->addOption("environment", "E", InputOption::VALUE_NONE, "Show the environment for the services");
|
$this->addOption("environment", "E", InputOption::VALUE_NONE, "Show the environment for the services");
|
||||||
$this->addOption("ports", "P", InputOption::VALUE_NONE, "Show the ports for the services");
|
$this->addOption("ports", "P", InputOption::VALUE_NONE, "Show the ports for the services");
|
||||||
|
$this->addOption("info", "I", InputOption::VALUE_NONE, "Show service information text if available");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
@ -25,10 +26,12 @@ class FindCommand extends Command
|
|||||||
|
|
||||||
$printEnvs = $input->getOption("environment");
|
$printEnvs = $input->getOption("environment");
|
||||||
$printPorts = $input->getOption("ports");
|
$printPorts = $input->getOption("ports");
|
||||||
|
$showInfo = $input->getOption("info");
|
||||||
|
|
||||||
$services = $serviceRegistry->findAllServices();
|
$services = $serviceRegistry->findAllServices();
|
||||||
$query = $input->getArgument("service");
|
$query = $input->getArgument("service");
|
||||||
|
|
||||||
|
|
||||||
$output->writeln($query?"Services matching <options=bold>{$query}</>:":"Available services:");
|
$output->writeln($query?"Services matching <options=bold>{$query}</>:":"Available services:");
|
||||||
foreach ($services as $service) {
|
foreach ($services as $service) {
|
||||||
$tags = $service['tags']??[];
|
$tags = $service['tags']??[];
|
||||||
@ -42,6 +45,10 @@ class FindCommand extends Command
|
|||||||
$tags = "";
|
$tags = "";
|
||||||
}
|
}
|
||||||
$output->writeln(sprintf(" <comment>%s</>: <info>%s</> <fg=cyan>%s</>", $service['name'], $service['description']??"?", $tags));
|
$output->writeln(sprintf(" <comment>%s</>: <info>%s</> <fg=cyan>%s</>", $service['name'], $service['description']??"?", $tags));
|
||||||
|
if ($showInfo && array_key_exists('info', $service)) {
|
||||||
|
$info = " ".strtr(wordwrap($service['info']), [ "\n" => "\n " ]);
|
||||||
|
$output->writeln("<fg=bright-green>".$info."</>");
|
||||||
|
}
|
||||||
if ($printEnvs) {
|
if ($printEnvs) {
|
||||||
foreach ($service['environment']??[] as $env=>$value) {
|
foreach ($service['environment']??[] as $env=>$value) {
|
||||||
$output->writeln(sprintf(" <fg=cyan>%s</>=<fg=magenta>%s</>", $env, $value));
|
$output->writeln(sprintf(" <fg=cyan>%s</>=<fg=magenta>%s</>", $env, $value));
|
||||||
|
@ -251,6 +251,10 @@ class ContainerManager
|
|||||||
|
|
||||||
$cmdl = 'docker '.join(' ',array_map('escapeshellarg', $args));
|
$cmdl = 'docker '.join(' ',array_map('escapeshellarg', $args));
|
||||||
|
|
||||||
|
$cmdl = preg_replace_callback('<\$\{(.+?)\}>', function ($v) use ($service) {
|
||||||
|
return $service['environment'][$v[1]]??null;
|
||||||
|
}, $cmdl);
|
||||||
|
|
||||||
echo "$ {$cmdl}\n";
|
echo "$ {$cmdl}\n";
|
||||||
passthru($cmdl);
|
passthru($cmdl);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user