From e12c9b38ea3c8abfee70cc81c6ba80fa90fabe11 Mon Sep 17 00:00:00 2001 From: miholeus Date: Thu, 6 Jul 2017 15:59:52 +0300 Subject: [PATCH 1/7] run local commands in credentials gatherer --- .../Services/Connections/Credentials/CredentialsGatherer.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Rocketeer/Services/Connections/Credentials/CredentialsGatherer.php b/src/Rocketeer/Services/Connections/Credentials/CredentialsGatherer.php index dee6690c0..f0e785fa1 100644 --- a/src/Rocketeer/Services/Connections/Credentials/CredentialsGatherer.php +++ b/src/Rocketeer/Services/Connections/Credentials/CredentialsGatherer.php @@ -50,6 +50,8 @@ public function getCredentials() */ public function getRepositoryCredentials() { + $this->rocketeer->setLocal(true); + $endpoint = $this->vcs->runLocally('currentEndpoint'); $user = $this->bash->runLocally('whoami'); From 2093053b93115175f585d6f7baa279a9f0db2a9c Mon Sep 17 00:00:00 2001 From: miholeus Date: Thu, 6 Jul 2017 17:01:46 +0300 Subject: [PATCH 2/7] set connection's root directory while ignition --- .../Services/Config/Definition/ConnectionsDefinition.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Rocketeer/Services/Config/Definition/ConnectionsDefinition.php b/src/Rocketeer/Services/Config/Definition/ConnectionsDefinition.php index 8475197a9..cf543d41c 100644 --- a/src/Rocketeer/Services/Config/Definition/ConnectionsDefinition.php +++ b/src/Rocketeer/Services/Config/Definition/ConnectionsDefinition.php @@ -135,7 +135,7 @@ protected function getConnectionNode($node, Fluent $connection) ->scalarNode('agent')->defaultTrue()->end() ->scalarNode('root_directory') ->info("The root directory where your applications will be deployed.\nThis path needs to start at the root, ie. start with a /") - ->defaultValue($connection['root']) + ->defaultValue($connection->root_directory) ->end() ->arrayNode('roles') ->info('The roles this server has, set to null if you do not use roles on your project') From a0e6ba74ed761a1be77887d58c158b1c210c836b Mon Sep 17 00:00:00 2001 From: miholeus Date: Thu, 6 Jul 2017 17:04:53 +0300 Subject: [PATCH 3/7] set connection's root directory while ignition --- .../Services/Config/Definition/ConnectionsDefinition.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Rocketeer/Services/Config/Definition/ConnectionsDefinition.php b/src/Rocketeer/Services/Config/Definition/ConnectionsDefinition.php index 8475197a9..cf543d41c 100644 --- a/src/Rocketeer/Services/Config/Definition/ConnectionsDefinition.php +++ b/src/Rocketeer/Services/Config/Definition/ConnectionsDefinition.php @@ -135,7 +135,7 @@ protected function getConnectionNode($node, Fluent $connection) ->scalarNode('agent')->defaultTrue()->end() ->scalarNode('root_directory') ->info("The root directory where your applications will be deployed.\nThis path needs to start at the root, ie. start with a /") - ->defaultValue($connection['root']) + ->defaultValue($connection->root_directory) ->end() ->arrayNode('roles') ->info('The roles this server has, set to null if you do not use roles on your project') From d4d30974a9e736d2d2d47c19729df0e931688af0 Mon Sep 17 00:00:00 2001 From: miholeus Date: Fri, 7 Jul 2017 11:08:53 +0300 Subject: [PATCH 4/7] exclude null values from location --- src/Rocketeer/Services/Connections/Shell/Modules/Binaries.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Rocketeer/Services/Connections/Shell/Modules/Binaries.php b/src/Rocketeer/Services/Connections/Shell/Modules/Binaries.php index d2827cce2..ba90cb6ee 100644 --- a/src/Rocketeer/Services/Connections/Shell/Modules/Binaries.php +++ b/src/Rocketeer/Services/Connections/Shell/Modules/Binaries.php @@ -92,6 +92,8 @@ public function which($binary, $fallback = null, $prompt = true) $locations[] = $fallback; } + $locations = array_diff($locations, array(null)); + // Add command prompt if possible if ($this->hasCommand() && $prompt) { $prompt = 'Binary "'.$binary.'" could not be found, please enter the path to it'; From 3a54297d6025f40aa38f46dc547ef123b6ab1593 Mon Sep 17 00:00:00 2001 From: miholeus Date: Tue, 25 Jul 2017 15:08:11 +0300 Subject: [PATCH 5/7] added port support to config --- .../Services/Config/Definition/ConnectionsDefinition.php | 1 + .../Services/Connections/Credentials/Keys/ConnectionKey.php | 1 + .../Services/Filesystem/ConnectionKeyAdapterFactory.php | 1 + 3 files changed, 3 insertions(+) diff --git a/src/Rocketeer/Services/Config/Definition/ConnectionsDefinition.php b/src/Rocketeer/Services/Config/Definition/ConnectionsDefinition.php index cf543d41c..1d6d0f9f2 100644 --- a/src/Rocketeer/Services/Config/Definition/ConnectionsDefinition.php +++ b/src/Rocketeer/Services/Config/Definition/ConnectionsDefinition.php @@ -128,6 +128,7 @@ protected function getConnectionNode($node, Fluent $connection) ->prototype('array') ->children() ->scalarNode('host')->defaultValue($connection->host)->end() + ->scalarNode('port')->defaultValue($connection->port)->end() ->scalarNode('username')->defaultValue($connection->username)->end() ->scalarNode('password')->defaultValue($connection->password)->end() ->scalarNode('key')->defaultValue($connection->key)->end() diff --git a/src/Rocketeer/Services/Connections/Credentials/Keys/ConnectionKey.php b/src/Rocketeer/Services/Connections/Credentials/Keys/ConnectionKey.php index a5b05d5f8..ade9888e7 100644 --- a/src/Rocketeer/Services/Connections/Credentials/Keys/ConnectionKey.php +++ b/src/Rocketeer/Services/Connections/Credentials/Keys/ConnectionKey.php @@ -16,6 +16,7 @@ * Represents a connection's identity and its credential. * * @property string $host + * @property string $port * @property string $username * @property string $password * @property string $key diff --git a/src/Rocketeer/Services/Filesystem/ConnectionKeyAdapterFactory.php b/src/Rocketeer/Services/Filesystem/ConnectionKeyAdapterFactory.php index ab7fca4ee..08129919e 100644 --- a/src/Rocketeer/Services/Filesystem/ConnectionKeyAdapterFactory.php +++ b/src/Rocketeer/Services/Filesystem/ConnectionKeyAdapterFactory.php @@ -34,6 +34,7 @@ public function getAdapter(ConnectionKey $connectionKey) return new $adapter([ 'host' => $connectionKey->host, + 'port' => $connectionKey->port, 'username' => $connectionKey->username, 'password' => $connectionKey->password, 'privateKey' => $connectionKey->key, From 59d71d6c32b80508c89f946ea7d484c5b362738f Mon Sep 17 00:00:00 2001 From: miholeus Date: Fri, 22 Dec 2017 13:23:06 +0300 Subject: [PATCH 6/7] save previous releases while deploying new one --- .../Services/Releases/ReleasesManager.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Rocketeer/Services/Releases/ReleasesManager.php b/src/Rocketeer/Services/Releases/ReleasesManager.php index cf235e71f..a9821d35a 100644 --- a/src/Rocketeer/Services/Releases/ReleasesManager.php +++ b/src/Rocketeer/Services/Releases/ReleasesManager.php @@ -109,18 +109,18 @@ public function getNonCurrentReleases() /** * Get an array of deprecated releases. * - * @param int|null $treshold + * @param int|null $threshold * * @return int[] */ - public function getDeprecatedReleases($treshold = null) + public function getDeprecatedReleases($threshold = null) { $releases = $this->getReleases(); - $treshold = $treshold ?: $this->config->get('remote.keep_releases'); + $threshold = $threshold ?: $this->config->get('remote.keep_releases'); // Get first X valid releases $keep = $this->getValidReleases(); - $keep = array_slice($keep, 0, $treshold); + $keep = array_slice($keep, 0, $threshold); // Compute diff $deprecated = array_diff($releases, $keep); @@ -136,6 +136,19 @@ public function getDeprecatedReleases($treshold = null) */ public function getValidReleases() { + $threshold = $this->config->get('remote.keep_releases'); + if ($threshold) { + $keepRelease = 0; + foreach ($this->state as &$state) { + $state = true; + $keepRelease++; + if ($keepRelease >= $threshold) { + break; + } + } + unset($state); + } + $valid = array_filter($this->state); $valid = array_keys($valid); From a0f62e5d7a6896496552d4516765707e5af04a07 Mon Sep 17 00:00:00 2001 From: miholeus Date: Fri, 22 Dec 2017 13:25:05 +0300 Subject: [PATCH 7/7] fixed bug that --on setting is not working --- .../Connections/ConnectionsHandler.php | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/Rocketeer/Services/Connections/ConnectionsHandler.php b/src/Rocketeer/Services/Connections/ConnectionsHandler.php index 23b1b791e..07586246b 100644 --- a/src/Rocketeer/Services/Connections/ConnectionsHandler.php +++ b/src/Rocketeer/Services/Connections/ConnectionsHandler.php @@ -179,9 +179,16 @@ public function isValidConnection($connection) */ public function getActiveConnections() { - return $this->getConnections()->filter(function (ConnectionInterface $connection) { + $connections = $this->getConnections()->filter(function (ConnectionInterface $connection) { return $this->isConnectionActive($connection); }); + // activate default connection if nothing was selected + if ($connections->count() == 0) { + $connections = $this->getConnections()->filter(function (ConnectionInterface $connection) { + return $this->isConnectionDefault($connection); + }); + } + return $connections; } /** @@ -212,6 +219,11 @@ public function setActiveConnections($connections) return $connection; }); +// $this->available = $this->available->filter(function (ConnectionInterface $connection){ +// if ($connection->isActive()) { +// return $connection; +// } +// }); } //////////////////////////////////////////////////////////////////////////////// @@ -371,14 +383,23 @@ public function setStage($stage) * @return bool */ protected function isConnectionActive(ConnectionInterface $connection) + { + return $connection->isActive(); + } + + /** + * @param ConnectionInterface $connection + * + * @return bool + */ + protected function isConnectionDefault(ConnectionInterface $connection) { $connectionKey = $connection->getConnectionKey(); $defaults = $this->getDefaultConnectionsHandles(); return in_array($connectionKey->toHandle(), $defaults, true) || - in_array($connectionKey->name, $defaults, true) || - $connection->isActive(); + in_array($connectionKey->name, $defaults, true); } /**