Move repository URL generation down to fetch_repository
We can't use config interpolation from oslo.config once we remove it and it won't solve this bug anyway because its template is static, so we should solve it where url is being used instead. Change-Id: I909e31c417508247456f2385dd23c049bcf688d8 Closes-Bug: #1609012
This commit is contained in:
parent
cb23aeba32
commit
8abb44ee31
@ -53,7 +53,6 @@ repositories_opts = [
|
||||
default='openstack',
|
||||
help='Gerrit project'),
|
||||
cfg.StrOpt('username',
|
||||
default='',
|
||||
help='Username when using git or ssh scheme'),
|
||||
cfg.ListOpt('names',
|
||||
default=DEFAULT_REPOS,
|
||||
@ -73,18 +72,17 @@ SCHEMA = {
|
||||
'port': {'type': 'integer'},
|
||||
'protocol': {'type': 'string'},
|
||||
'project': {'type': 'string'},
|
||||
'username': {'type': 'string'},
|
||||
'username': {'anyOf': [{'type': 'string'}, {'type': 'null'}]},
|
||||
'names': {'type': 'array', 'items': {'type': 'string'}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for repo in DEFAULT_REPOS:
|
||||
url = '$protocol://$username@$hostname:$port/$project/'
|
||||
option = cfg.StrOpt(repo, default=url + repo)
|
||||
option = cfg.StrOpt(repo)
|
||||
repositories_opts.append(option)
|
||||
SCHEMA['repositories']['properties'][repo.replace('-', '_')] = \
|
||||
{'type': 'string'}
|
||||
{'anyOf': [{'type': 'string'}, {'type': 'null'}]}
|
||||
|
||||
repositories_opt_group = cfg.OptGroup(name='repositories',
|
||||
title='Git repositories for components')
|
||||
|
@ -20,6 +20,14 @@ def fetch_repository(repository_name):
|
||||
LOG.info('%s was already cloned, skipping', repository_name)
|
||||
return
|
||||
git_url = getattr(CONF.repositories, repository_name.replace('-', '_'))
|
||||
if git_url is None:
|
||||
username = CONF.repositories.username
|
||||
if username is None:
|
||||
username = ''
|
||||
else:
|
||||
username = username + '@'
|
||||
fmt = '{0.protocol}://{1}{0.hostname}:{0.port}/{0.project}/{2}'
|
||||
git_url = fmt.format(CONF.repositories, username, repository_name)
|
||||
git.Repo.clone_from(git_url, dest_dir)
|
||||
LOG.info('Cloned %s repo', repository_name)
|
||||
|
||||
|
@ -35,8 +35,8 @@ class TestFetch(base.TestCase):
|
||||
'fuel-ccp-rabbitmq',
|
||||
'fuel-ccp-stacklight']
|
||||
expected_calls = [
|
||||
mock.call('https://%s@review.openstack.org:443/openstack/%s' % (
|
||||
'', component), os.path.join(self.tmp_path, component))
|
||||
mock.call('https://review.openstack.org:443/openstack/%s' % (
|
||||
component), os.path.join(self.tmp_path, component))
|
||||
for component in components
|
||||
]
|
||||
for component, expected_call in zip(components, expected_calls):
|
||||
|
Loading…
Reference in New Issue
Block a user