Allow obtaining specifically tagged governance data
The Election repo need to collect governance data at a specific tag. Allow this for remote (governance) repos. We don't need to do this for a local (governance) review as we can just ``git checkout`` the tag. Change-Id: Ib94d5f0c3df8538af753b3b46c6a11ceff8fef53
This commit is contained in:
parent
540ed34106
commit
e4196ed6ea
@ -13,6 +13,7 @@
|
||||
"""Work with the governance repository.
|
||||
"""
|
||||
|
||||
import collections
|
||||
import logging
|
||||
import os.path
|
||||
import weakref
|
||||
@ -128,6 +129,25 @@ class Governance(object):
|
||||
|
||||
self._teams = [Team(n, i) for n, i in self._team_data.items()]
|
||||
|
||||
@classmethod
|
||||
def _fixup_wgs_data(cls, wgs_data):
|
||||
# For some period of time reference/foundation-board-repos.yaml
|
||||
# was the wrong data structure. Each WG should be a list of dict()s
|
||||
# where each dict has a single key 'repo' and a str() value.
|
||||
# The incorrect format is a list of dict()s with a single key 'repo'
|
||||
# but the value is a list of strings.
|
||||
# Transform the incorrect format into the correct one so callers don't
|
||||
# notice.
|
||||
for wg_name in list(wgs_data.keys()):
|
||||
wg_info = wgs_data[wg_name]
|
||||
_tmp = []
|
||||
for idx in range(len(wg_info)):
|
||||
if isinstance(wg_info[idx].get('repo', ''), list):
|
||||
for repo in wg_info[idx]['repo']:
|
||||
_tmp.append(collections.OrderedDict(repo=repo))
|
||||
if _tmp:
|
||||
wgs_data[wg_name] = _tmp
|
||||
|
||||
@classmethod
|
||||
def from_local_repo(cls, repo_dir='.'):
|
||||
team_filename = os.path.join(repo_dir, cls._projects_filename)
|
||||
@ -141,30 +161,35 @@ class Governance(object):
|
||||
|
||||
wgs_filename = os.path.join(repo_dir, cls._wgs_repos_filename)
|
||||
wgs_data = _yamlutils.load_from_file(wgs_filename)
|
||||
cls._fixup_wgs_data(wgs_data)
|
||||
|
||||
return cls(team_data, tc_data, sigs_data, wgs_data)
|
||||
|
||||
@classmethod
|
||||
def from_remote_repo(cls, repo_url_base=REPO_URL_BASE):
|
||||
def from_remote_repo(cls, repo_url_base=REPO_URL_BASE, gittag=None):
|
||||
query_options = {}
|
||||
if gittag:
|
||||
query_options.update({'h': gittag})
|
||||
team_url = REPO_URL_BASE + '/reference/projects.yaml'
|
||||
LOG.debug('fetching team data from %s', team_url)
|
||||
r = requests.get(team_url)
|
||||
r = requests.get(team_url, params=query_options)
|
||||
team_data = _yamlutils.loads(r.text)
|
||||
|
||||
tc_url = REPO_URL_BASE + '/reference/technical-committee-repos.yaml'
|
||||
LOG.debug('fetching TC data from %s', tc_url)
|
||||
r = requests.get(tc_url)
|
||||
r = requests.get(tc_url, params=query_options)
|
||||
tc_data = _yamlutils.loads(r.text)
|
||||
|
||||
sigs_url = REPO_URL_BASE + '/reference/sigs-repos.yaml'
|
||||
LOG.debug('fetching SIGs data from %s', sigs_url)
|
||||
r = requests.get(sigs_url)
|
||||
r = requests.get(sigs_url, params=query_options)
|
||||
sigs_data = _yamlutils.loads(r.text)
|
||||
|
||||
wgs_url = REPO_URL_BASE + '/reference/foundation-board-repos.yaml'
|
||||
LOG.debug('fetching WGs data from %s', wgs_url)
|
||||
r = requests.get(wgs_url)
|
||||
r = requests.get(wgs_url, params=query_options)
|
||||
wgs_data = _yamlutils.loads(r.text)
|
||||
cls._fixup_wgs_data(wgs_data)
|
||||
|
||||
return cls(team_data, tc_data, sigs_data, wgs_data)
|
||||
|
||||
|
@ -234,3 +234,19 @@ class TestTeamProperties(base.BaseTestCase):
|
||||
def test_mission(self):
|
||||
self.assertEqual('mission statement', self.team_with.mission)
|
||||
self.assertIsNone(self.team_without.mission)
|
||||
|
||||
|
||||
class TestFixupWGData(base.BaseTestCase):
|
||||
def test_incorrect_format(self):
|
||||
_wgs_data = _yamlutils.loads("""
|
||||
---
|
||||
# List of repositories owned by Foundation board and subcommittes
|
||||
Interop Working Group:
|
||||
- repo:
|
||||
- openstack/interop
|
||||
- openstack/refstack-client
|
||||
- openstack/refstack
|
||||
- openstack/python-tempestconf
|
||||
""")
|
||||
governance.Governance._fixup_wgs_data(_wgs_data)
|
||||
self.assertEqual(WGS_DATA, _wgs_data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user