Skip to content

Commit

Permalink
Re-allow output from "ssh-cert:load --refresh-only", now that quiet m…
Browse files Browse the repository at this point in the history
…ode works (#1491)

This partially reverts 29a9285
  • Loading branch information
pjcdawkins authored Oct 15, 2024
1 parent 0a45403 commit 32b225c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/Command/SshCert/SshCertLoadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ protected function configure()
{
$this
->setName('ssh-cert:load')
->addOption('refresh-only', null, InputOption::VALUE_NONE,
'Only refresh the certificate, if necessary (do not write SSH config).'
. ' Unless verbose mode is used, this will not output messages.')
->addOption('refresh-only', null, InputOption::VALUE_NONE, 'Only refresh the certificate, if necessary (do not write SSH config)')
->addOption('new', null, InputOption::VALUE_NONE, 'Force the certificate to be refreshed')
->addOption('new-key', null, InputOption::VALUE_NONE, 'Force a new key pair to be generated')
->setDescription('Generate an SSH certificate');
Expand Down Expand Up @@ -47,7 +45,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$refresh = true;
if (getenv(Ssh::SSH_NO_REFRESH_ENV_VAR)) {
if ($refreshOnly && !$this->stdErr->isVerbose()) {
if ($refreshOnly && $this->stdErr->isQuiet()) {
return 0;
}
$this->stdErr->writeln(sprintf('Not refreshing SSH certificate (<comment>%s</comment> variable is set)', Ssh::SSH_NO_REFRESH_ENV_VAR));
Expand All @@ -58,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
&& !$input->getOption('new')
&& !$input->getOption('new-key')
&& $certifier->isValid($sshCert)) {
if ($refreshOnly && !$this->stdErr->isVerbose()) {
if ($refreshOnly && $this->stdErr->isQuiet()) {
return 0;
}
$this->stdErr->writeln('A valid SSH certificate exists');
Expand All @@ -73,7 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (!$sshConfig->checkRequiredVersion()) {
return 1;
}
if ($refreshOnly && !$this->stdErr->isVerbose()) {
if ($refreshOnly && $this->stdErr->isQuiet()) {
$certifier->generateCertificate($sshCert, $input->getOption('new-key'));
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Service/SshConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function configureSessionSsh()
$certificate = $this->certifier->getExistingCertificate();
if ($certificate) {
$executable = $this->config->get('application.executable');
$refreshCommand = sprintf('%s ssh-cert:load --refresh-only --yes', $executable);
$refreshCommand = sprintf('%s ssh-cert:load --refresh-only --yes --quiet', $executable);

// On shells where it might work (POSIX compliant), skip refreshing
// the certificate when the CLI_SSH_NO_REFRESH env var is set to 1.
Expand Down

0 comments on commit 32b225c

Please sign in to comment.