Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
Backport key transposing feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Anahkiasen committed Dec 31, 2016
1 parent ef29590 commit 3c4994d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Rocketeer/Services/Connections/ConnectionsHandler.php
Expand Up @@ -196,8 +196,16 @@ public function getAvailableConnections()

// Unify multiservers
foreach ($connections as $key => $servers) {
$servers = Arr::get($servers, 'servers', [$servers]);
$connections[$key] = ['servers' => array_values($servers)];
$servers = Arr::get($servers, 'servers', [$servers]);
$servers = array_values($servers);

foreach ($servers as $serverKey => $server) {
if ($server && array_key_exists('key', $server)) {
$servers[$serverKey]['key'] = str_replace('~/', $this->paths->getUserHomeFolder().'/', $server['key']);
}
}

$connections[$key] = ['servers' => $servers];
}

return $connections;
Expand Down
14 changes: 14 additions & 0 deletions tests/Services/Connections/ConnectionsHandlerTest.php
Expand Up @@ -283,6 +283,20 @@ public function testCanHaveMultipleServerConnections()
$this->assertEquals('production-multiserver/2', $this->connections->getHandle('production-multiserver', 2));
}

public function testCanExpandPathsAtRuntime()
{
$this->swapConfig([
'rocketeer::connections' => [
'production' => [
'host' => 'foo.com',
'key' => '~/.ssh/id_rsa',
],
],
]);

$this->assertEquals($this->paths->getUserHomeFolder().'/.ssh/id_rsa', $this->connections->getServerCredentials()['key']);
}

////////////////////////////////////////////////////////////////////
//////////////////////////////// HELPERS ///////////////////////////
////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 3c4994d

Please sign in to comment.