summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Poignant <oliver@poignant.se>2016-05-29 12:22:16 +0200
committerOliver Poignant <oliver@poignant.se>2016-05-29 12:22:22 +0200
commit9538eeae249c694feb3a2494804f36857e95c4af (patch)
treead5e0e85427df7ad1f30a98684439cf66ee3ff5f
parent208ebb8641ab1f9d58ea69377773216af36829f6 (diff)
downloadGit-Auto-Deploy-9538eeae249c694feb3a2494804f36857e95c4af.zip
Git-Auto-Deploy-9538eeae249c694feb3a2494804f36857e95c4af.tar.gz
Git-Auto-Deploy-9538eeae249c694feb3a2494804f36857e95c4af.tar.bz2
Renamed and fixed bug in keyscan feature
-rw-r--r--docs/Configuration.md2
-rw-r--r--gitautodeploy/cli/config.py10
-rw-r--r--gitautodeploy/gitautodeploy.py24
3 files changed, 18 insertions, 18 deletions
diff --git a/docs/Configuration.md b/docs/Configuration.md
index 3128697..c7248ca 100644
--- a/docs/Configuration.md
+++ b/docs/Configuration.md
@@ -16,7 +16,7 @@ Command line option | Environment variable | Config attribute | Description
--host <host> | GAD_HOST | host | Address to bind to
--port <port> | GAD_PORT | port | Port to bind to
--force | GAD_FORCE | | Kill any process using the configured port
---ssh-keygen | GAD_SSH_KEYGEN | | Scan repository hosts for ssh keys
+--ssh-keyscan | GAD_SSH_KEYSCAN | | Scan repository hosts for ssh keys and add them to $HOME/.ssh/known_hosts
# Configuration file options
The configuration file is formatted according to a `JSON` inspired format, with the additional feature of supporting inline comments. The possible root elements are
diff --git a/gitautodeploy/cli/config.py b/gitautodeploy/cli/config.py
index cd8c54c..4ca677d 100644
--- a/gitautodeploy/cli/config.py
+++ b/gitautodeploy/cli/config.py
@@ -5,7 +5,7 @@ def get_config_defaults():
config['quiet'] = False
config['daemon-mode'] = False
config['config'] = None
- config['ssh-keygen'] = False
+ config['ssh-keyscan'] = False
config['force'] = False
config['ssl'] = False
config['ssl-pem-file'] = '~/.gitautodeploy.pem'
@@ -44,8 +44,8 @@ def get_config_from_environment():
if 'GAD_CONFIG' in os.environ:
config['config'] = os.environ['GAD_CONFIG']
- if 'GAD_SSH_KEYGEN' in os.environ:
- config['ssh-keygen'] = True
+ if 'GAD_SSH_KEYSCAN' in os.environ:
+ config['ssh-keyscan'] = True
if 'GAD_FORCE' in os.environ:
config['force'] = True
@@ -90,9 +90,9 @@ def get_config_from_argv(argv):
dest="config",
type=str)
- parser.add_argument("--ssh-keygen",
+ parser.add_argument("--ssh-keyscan",
help="scan repository hosts for ssh keys",
- dest="ssh-keygen",
+ dest="ssh-keyscan",
action="store_true")
parser.add_argument("--force",
diff --git a/gitautodeploy/gitautodeploy.py b/gitautodeploy/gitautodeploy.py
index 8f3b172..c553362 100644
--- a/gitautodeploy/gitautodeploy.py
+++ b/gitautodeploy/gitautodeploy.py
@@ -130,22 +130,22 @@ class GitAutoDeploy(object):
logger = logging.getLogger()
for repository in self._config['repositories']:
+
+ if not 'url' in repository:
+ continue
- url = repository['url']
- logger.info("Scanning repository: %s" % url)
- m = re.match('.*@(.*?):', url)
+ logger.info("Scanning repository: %s" % repository['url'])
+ m = re.match('[^\@]+\@([^\:\/]+)(:(\d+))?', repository['url'])
if m is not None:
- port = repository['port']
- port = '' if port is None else ('-p' + port)
- ProcessWrapper().call(['ssh-keyscan -t ecdsa,rsa ' +
- port + ' ' +
- m.group(1) +
- ' >> ' +
- '$HOME/.ssh/known_hosts'], shell=True)
+ host = m.group(1)
+ port = m.group(3)
+ port_arg = '' if port is None else ('-p %s ' % port)
+ cmd = 'ssh-keyscan %s%s >> $HOME/.ssh/known_hosts' % (port_arg, host)
+ ProcessWrapper().call([cmd], shell=True)
else:
- logger.error('Could not find regexp match in path: %s' % url)
+ logger.error('Could not find regexp match in path: %s' % repository['url'])
def kill_conflicting_processes(self):
"""Attempt to kill any process already using the configured port."""
@@ -281,7 +281,7 @@ class GitAutoDeploy(object):
fileHandler.setFormatter(logFormatter)
logger.addHandler(fileHandler)
- if 'ssh-keygen' in self._config and self._config['ssh-keygen']:
+ if 'ssh-keyscan' in self._config and self._config['ssh-keyscan']:
logger.info('Scanning repository hosts for ssh keys...')
self.ssh_key_scan()