extend to config_inheritance

This commit is contained in:
Tomas Kopecek 2020-09-24 15:46:08 +02:00
parent 73aa437d45
commit fedf3ee9f9
3 changed files with 11 additions and 7 deletions

View file

@ -4897,8 +4897,8 @@ def anon_handle_taginfo(goptions, session, args):
print("Tag options:")
for key in sorted(info['extra'].keys()):
line = " %s : %s" % (key, pprint.pformat(info['extra'][key]))
if key in info.get('extra_inheritance', []):
line = "%-30s [%s]" % (line, info['extra_inheritance'][key]['name'])
if key in info.get('config_inheritance', {}).get('extra', []):
line = "%-30s [%s]" % (line, info['config_inheritance']['extra'][key]['name'])
print(line)
dest_targets = session.getBuildTargets(destTagID=info['id'], **event_opts)
build_targets = session.getBuildTargets(buildTagID=info['id'], **event_opts)

View file

@ -11949,7 +11949,7 @@ class RootExports(object):
def getBuildConfig(self, tag, event=None):
"""Return build configuration associated with a tag"""
taginfo = get_tag(tag, strict=True, event=event, blocked=True)
taginfo['extra_inheritance'] = {}
taginfo['config_inheritance'] = {'extra': {}, 'arches': None}
order = readFullInheritance(taginfo['id'], event=event)
# follow inheritance for arches and extra
for link in order:
@ -11958,10 +11958,11 @@ class RootExports(object):
ancestor = get_tag(link['parent_id'], strict=True, event=event, blocked=True)
if taginfo['arches'] is None and ancestor['arches'] is not None:
taginfo['arches'] = ancestor['arches']
taginfo['config_inheritance']['arches'] = dslice(ancestor, ('id', 'name'))
for key in ancestor['extra']:
if key not in taginfo['extra']:
taginfo['extra'][key] = ancestor['extra'][key]
taginfo['extra_inheritance'][key] = dslice(ancestor, ('id', 'name'))
taginfo['config_inheritance']['extra'][key] = dslice(ancestor, ('id', 'name'))
# cleanup extras by blocked
for k, v in list(taginfo['extra'].items()):
if v[0]:

View file

@ -22,7 +22,7 @@ class TestGetBuildConfig(unittest.TestCase):
'id': 123,
'name': tag,
'extra': {},
'extra_inheritance': {},
'config_inheritance': {'extra': {}, 'arches': None},
})
@mock.patch('kojihub.readFullInheritance')
@ -70,7 +70,10 @@ class TestGetBuildConfig(unittest.TestCase):
self.assertEqual(taginfo, {
'arches': 'x86_64',
'extra': {'value': 'inherited'},
'extra_inheritance': {'value': {'id': 1234, 'name': 'parent'}},
'config_inheritance': {
'arches': {'id': 1234, 'name': 'parent'},
'extra' : {'value': {'id': 1234, 'name': 'parent'}}
},
'id': 123,
'name': 'tag_name'
})
@ -117,7 +120,7 @@ class TestGetBuildConfig(unittest.TestCase):
self.assertEqual(taginfo, {
'arches': None,
'extra': {},
'extra_inheritance': {},
'config_inheritance': {'extra': {}, 'arches': None},
'id': 123,
'name': 'tag_name'
})