mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-07-17 11:30:19 +08:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user