mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 12:30:56 +01:00
Check to make sure credential is not null in SSH command interface
Summary: This adds a check to make sure the credential exists when loading it in the Drydock SSH interface. This effectively turns a fatal error (calling a method on a non-object) into a catchable exception. Test Plan: Had a badly configured resource, saw the exception appear instead of daemon fataling. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11530
This commit is contained in:
parent
6e723c5c5a
commit
82f506f175
1 changed files with 6 additions and 0 deletions
|
@ -16,6 +16,12 @@ final class DrydockSSHCommandInterface extends DrydockCommandInterface {
|
|||
->needSecrets(true)
|
||||
->executeOne();
|
||||
|
||||
if ($credential === null) {
|
||||
throw new Exception(pht(
|
||||
'There is no credential with ID %d.',
|
||||
$this->getConfig('credential')));
|
||||
}
|
||||
|
||||
if ($credential->getProvidesType() !==
|
||||
PassphraseCredentialTypeSSHPrivateKey::PROVIDES_TYPE) {
|
||||
throw new Exception('Only private key credentials are supported.');
|
||||
|
|
Loading…
Reference in a new issue