Implement Keystone environment deployments
This commit is contained in:
20
app/Services/Operations/SshRemoteCommandRunner.php
Normal file
20
app/Services/Operations/SshRemoteCommandRunner.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Operations;
|
||||
|
||||
use App\Models\Server;
|
||||
use RuntimeException;
|
||||
|
||||
class SshRemoteCommandRunner implements RemoteCommandRunner
|
||||
{
|
||||
public function run(Server $server, string $script): string
|
||||
{
|
||||
$result = $server->sshClient()->execute($script);
|
||||
|
||||
if (! $result->isSuccessful()) {
|
||||
throw new RuntimeException(trim($result->getErrorOutput()) ?: 'Remote command failed.');
|
||||
}
|
||||
|
||||
return trim($result->getOutput());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user