diff --git a/fuel_ccp/config/repositories.py b/fuel_ccp/config/repositories.py index 2ca107c0..54b92309 100644 --- a/fuel_ccp/config/repositories.py +++ b/fuel_ccp/config/repositories.py @@ -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') diff --git a/fuel_ccp/fetch.py b/fuel_ccp/fetch.py index d1878189..37a563e0 100644 --- a/fuel_ccp/fetch.py +++ b/fuel_ccp/fetch.py @@ -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) diff --git a/fuel_ccp/tests/test_fetch.py b/fuel_ccp/tests/test_fetch.py index 100dbf07..18221e29 100644 --- a/fuel_ccp/tests/test_fetch.py +++ b/fuel_ccp/tests/test_fetch.py @@ -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):