mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-04 19:28:49 +08:00
Fix #126 - remove Builder class
This commit is contained in:
@@ -145,6 +145,46 @@ class GenericBuilder(six.with_metaclass(ABCMeta)):
|
||||
|
||||
backend = "generic"
|
||||
|
||||
@classmethod
|
||||
def create(cls, owner, module, backend, config, **extra):
|
||||
"""
|
||||
:param owner: a string representing who kicked off the builds
|
||||
:param module: a module string e.g. 'testmodule-1.0'
|
||||
:param backend: a string representing backend e.g. 'koji'
|
||||
:param config: instance of module_build_service.config.Config
|
||||
|
||||
Any additional arguments are optional extras which can be passed along
|
||||
and are implementation-dependent.
|
||||
"""
|
||||
|
||||
if isinstance(config.system, Mock):
|
||||
return KojiModuleBuilder(owner=owner, module=module,
|
||||
config=config, **extra)
|
||||
elif backend == "koji":
|
||||
return KojiModuleBuilder(owner=owner, module=module,
|
||||
config=config, **extra)
|
||||
elif backend == "copr":
|
||||
return CoprModuleBuilder(owner=owner, module=module,
|
||||
config=config, **extra)
|
||||
else:
|
||||
raise ValueError("Builder backend='%s' not recognized" % backend)
|
||||
|
||||
@classmethod
|
||||
def tag_to_repo(cls, backend, config, tag_name, arch):
|
||||
"""
|
||||
:param backend: a string representing the backend e.g. 'koji'.
|
||||
:param config: instance of rida.config.Config
|
||||
:param tag_name: Tag for which the repository is returned
|
||||
:param arch: Architecture for which the repository is returned
|
||||
|
||||
Returns URL of repository containing the built artifacts for
|
||||
the tag with particular name and architecture.
|
||||
"""
|
||||
if backend == "koji":
|
||||
return KojiModuleBuilder.repo_from_tag(config, tag_name, arch)
|
||||
else:
|
||||
raise ValueError("Builder backend='%s' not recognized" % backend)
|
||||
|
||||
@abstractmethod
|
||||
def buildroot_connect(self):
|
||||
"""
|
||||
@@ -226,7 +266,7 @@ class GenericBuilder(six.with_metaclass(ABCMeta)):
|
||||
|
||||
@classmethod
|
||||
@abstractmethod
|
||||
def tag_to_repo(self, config, tag_name, arch):
|
||||
def repo_from_tag(self, config, tag_name, arch):
|
||||
"""
|
||||
:param config: instance of rida.config.Config
|
||||
:param tag_name: Tag for which the repository is returned
|
||||
@@ -237,49 +277,6 @@ class GenericBuilder(six.with_metaclass(ABCMeta)):
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
class Builder(object):
|
||||
"""Wrapper class"""
|
||||
|
||||
def __new__(cls, owner, module, backend, config, **extra):
|
||||
"""
|
||||
:param owner: a string representing who kicked off the builds
|
||||
:param module: a module string e.g. 'testmodule-1.0'
|
||||
:param backend: a string representing backend e.g. 'koji'
|
||||
:param config: instance of module_build_service.config.Config
|
||||
|
||||
Any additional arguments are optional extras which can be passed along
|
||||
and are implementation-dependent.
|
||||
"""
|
||||
|
||||
if isinstance(config.system, Mock):
|
||||
return KojiModuleBuilder(owner=owner, module=module,
|
||||
config=config, **extra)
|
||||
elif backend == "koji":
|
||||
return KojiModuleBuilder(owner=owner, module=module,
|
||||
config=config, **extra)
|
||||
elif backend == "copr":
|
||||
return CoprModuleBuilder(owner=owner, module=module,
|
||||
config=config, **extra)
|
||||
else:
|
||||
raise ValueError("Builder backend='%s' not recognized" % backend)
|
||||
|
||||
@classmethod
|
||||
def tag_to_repo(cls, backend, config, tag_name, arch):
|
||||
"""
|
||||
:param backend: a string representing the backend e.g. 'koji'.
|
||||
:param config: instance of rida.config.Config
|
||||
:param tag_name: Tag for which the repository is returned
|
||||
:param arch: Architecture for which the repository is returned
|
||||
|
||||
Returns URL of repository containing the built artifacts for
|
||||
the tag with particular name and architecture.
|
||||
"""
|
||||
if backend == "koji":
|
||||
return KojiModuleBuilder.tag_to_repo(config, tag_name, arch)
|
||||
else:
|
||||
raise ValueError("Builder backend='%s' not recognized" % backend)
|
||||
|
||||
|
||||
class KojiModuleBuilder(GenericBuilder):
|
||||
""" Koji specific builder class """
|
||||
|
||||
@@ -608,7 +605,7 @@ chmod 644 %buildroot/%_rpmconfigdir/macros.d/macros.modules
|
||||
return task_id, state, reason, None
|
||||
|
||||
@classmethod
|
||||
def tag_to_repo(cls, config, tag_name, arch):
|
||||
def repo_from_tag(cls, config, tag_name, arch):
|
||||
"""
|
||||
:param config: instance of rida.config.Config
|
||||
:param tag_name: Tag for which the repository is returned
|
||||
|
||||
@@ -77,8 +77,8 @@ def _finalize(config, session, msg, state):
|
||||
# And install the macros.
|
||||
module_name = parent.name
|
||||
tag = parent.koji_tag
|
||||
builder = module_build_service.builder.Builder(parent.owner, module_name, config.system,
|
||||
config, tag_name=tag)
|
||||
builder = module_build_service.builder.GenericBuilder.create(
|
||||
parent.owner, module_name, config.system, config, tag_name=tag)
|
||||
builder.buildroot_connect()
|
||||
# tag && add to srpm-build group
|
||||
nvr = "{}-{}-{}".format(msg.build_name, msg.build_version,
|
||||
|
||||
@@ -119,8 +119,8 @@ def wait(config, session, msg):
|
||||
log.debug("Assigning koji tag=%s to module build" % tag)
|
||||
build.koji_tag = tag
|
||||
|
||||
builder = module_build_service.builder.Builder(build.owner, build.name, config.system, config,
|
||||
tag_name=tag)
|
||||
builder = module_build_service.builder.GenericBuilder.create(
|
||||
build.owner, build.name, config.system, config, tag_name=tag)
|
||||
build.buildroot_task_id = builder.buildroot_connect()
|
||||
log.debug("Adding dependencies %s into buildroot for module %s" % (dependencies, module_info))
|
||||
builder.buildroot_add_repos(dependencies)
|
||||
|
||||
@@ -79,8 +79,9 @@ def done(config, session, msg):
|
||||
log.warn("Odd! All components in batch failed for %r." % module_build)
|
||||
return
|
||||
|
||||
builder = module_build_service.builder.Builder(module_build.owner, module_build.name,
|
||||
config.system, config, tag_name=tag)
|
||||
builder = module_build_service.builder.GenericBuilder.create(
|
||||
module_build.owner, module_build.name, config.system, config,
|
||||
tag_name=tag)
|
||||
builder.buildroot_connect()
|
||||
|
||||
# Ok, for the subset of builds that did complete successfully, check to
|
||||
|
||||
@@ -40,7 +40,7 @@ class TestKojiBuilder(unittest.TestCase):
|
||||
""" Test that when a repo msg hits us and we have no match,
|
||||
that we do nothing gracefully.
|
||||
"""
|
||||
repo = module_build_service.builder.Builder.tag_to_repo(
|
||||
repo = module_build_service.builder.GenericBuilder.tag_to_repo(
|
||||
"koji", self.config,
|
||||
"module-base-runtime-0.25-9",
|
||||
"x86_64")
|
||||
|
||||
Reference in New Issue
Block a user