-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add DockerSSH adapter using a 'docker context'
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Utopia\Orchestration\Adapter; | ||
|
||
use Utopia\CLI\Console; | ||
use Utopia\Orchestration\Adapter\DockerCLI; | ||
use Utopia\Orchestration\Exception\Orchestration; | ||
|
||
class DockerSSH extends DockerCLI | ||
{ | ||
/** | ||
* Constructor | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(string $sshHost, string $sshUser) | ||
{ | ||
$output = ''; | ||
if (! Console::execute("docker context create --docker host=ssh://{$sshUser}@{$sshHost} ssh", '', $output)) { | ||
throw new Orchestration("Docker Error: {$output}"); | ||
} | ||
$output = ''; | ||
if (! Console::execute('docker context use ssh', '', $output)) { | ||
throw new Orchestration("Docker Error: {$output}"); | ||
} | ||
} | ||
} |