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

@@ -21,8 +21,6 @@
#
# Written by Matt Prahl <mprahl@redhat.com>
import hashlib
from module_build_service import log
from module_build_service.resolver.base import GenericResolver
from module_build_service import models
@@ -67,21 +65,6 @@ class DBResolver(GenericResolver):
"Cannot find any module builds for %s:%s" % (name, stream))
return [build.mmd() for build in builds]
def get_module_tag(self, name, stream, version, context, strict=False):
"""
Gets the module tag from the resolver. Since the resolver is the DB, it is just generated
here.
:param name: a string of the module's name
:param stream: a string of the module's stream
:param version: a string or int of the module's version
:param context: a string of the module's context
:kwarg strict: Here solely for compatibility with the base class' function signature
:return: a string of the tag to use
"""
# This algorithm mimicks what pdc-updater does
tag_str = '.'.join([name, stream, str(version), context])
return 'module-{0}'.format(hashlib.sha1(tag_str).hexdigest()[:16])
def resolve_profiles(self, mmd, keys):
"""
Returns a dictionary with keys set according the `keys` parameters and values