Generate koji tag from MBS and use informative name

koji now supports tags with max length of 256, we can use
more informative tag name instead of the hash one.

The new format of koji tag name is:

    module-<name>-<stream>-<version>-<context>

However when the generated tag's length > (256 - len('build')), we
fallback to the old way of name in hash format (module-<hash>).

In this change, koji tag is always generated from MBS itself, even
with pdc resolver.

FIXES: #918 #925
This commit is contained in:
Qixiang Wan
2018-04-23 09:41:53 +08:00
parent 8351713828
commit 8b807a9fcd
9 changed files with 49 additions and 45 deletions

View File

@@ -93,6 +93,27 @@ def module_build_state_from_msg(msg):
return state
def generate_koji_tag(name, stream, version, context):
"""
Generate a koji tag from name, stream, version and context.
:param name: a module's name
:param stream: a module's stream
:param version: a module's version
:param context: a module's context
:return: a Koji tag
"""
nsvc_list = [name, stream, str(version), context]
nsvc_tag = 'module-' + '-'.join(nsvc_list)
if len(nsvc_tag) + len('-build') > 256:
# Koji supports tag names with a max length of 256, fallback
# to the old way of 'module-<hash>' if the generated koji tag
# name is too long
nsvc_hash = hashlib.sha1('.'.join(nsvc_list)).hexdigest()[:16]
return 'module-' + nsvc_hash
return nsvc_tag
def validate_koji_tag(tag_arg_names, pre='', post='-', dict_key='name'):
"""
Used as a decorator validates koji tag arg(s)' value(s)