mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-13 15:39:50 +08:00
Allow specifying a specific module build to reuse components from
This resolves #1296.
This commit is contained in:
@@ -877,6 +877,7 @@ class ModuleBuild(MBSBase):
|
||||
"build_context": self.build_context,
|
||||
"modulemd": self.modulemd,
|
||||
"ref_build_context": self.ref_build_context,
|
||||
"reused_module_id": self.reused_module_id,
|
||||
"runtime_context": self.runtime_context,
|
||||
"state_trace": [
|
||||
{
|
||||
|
||||
@@ -1014,6 +1014,7 @@ def submit_module_build(username, mmd, params):
|
||||
scmurl=params.get("scmurl"),
|
||||
username=username,
|
||||
rebuild_strategy=params.get("rebuild_strategy"),
|
||||
reused_module_id=params.get("reuse_components_from"),
|
||||
scratch=params.get("scratch"),
|
||||
srpms=params.get("srpms"),
|
||||
)
|
||||
|
||||
@@ -305,6 +305,7 @@ class BaseHandler(object):
|
||||
"module_name",
|
||||
"owner",
|
||||
"rebuild_strategy",
|
||||
"reuse_components_from",
|
||||
"require_overrides",
|
||||
"scmurl",
|
||||
"scratch",
|
||||
@@ -382,6 +383,40 @@ class BaseHandler(object):
|
||||
self._validate_dep_overrides_format("buildrequire_overrides")
|
||||
self._validate_dep_overrides_format("require_overrides")
|
||||
|
||||
if "reuse_components_from" in self.data:
|
||||
if "rebuild_strategy" in self.data and self.data["rebuild_strategy"] == "all":
|
||||
raise ValidationError(
|
||||
'You cannot specify the parameter "reuse_components_from" when the '
|
||||
'"rebuild_strategy" parameter is set to "all"'
|
||||
)
|
||||
|
||||
invalid_identifier_msg = (
|
||||
'The parameter "reuse_components_from" contains an invalid module identifier')
|
||||
|
||||
if isinstance(self.data["reuse_components_from"], int):
|
||||
reuse_module = models.ModuleBuild.get_by_id(
|
||||
db.session, self.data["reuse_components_from"])
|
||||
elif isinstance(self.data["reuse_components_from"], string_types):
|
||||
try:
|
||||
n, s, v, c = self.data["reuse_components_from"].split(":")
|
||||
except ValueError:
|
||||
raise ValidationError(invalid_identifier_msg)
|
||||
reuse_module = models.ModuleBuild.get_build_from_nsvc(db.session, n, s, v, c)
|
||||
else:
|
||||
raise ValidationError(invalid_identifier_msg)
|
||||
|
||||
if not reuse_module:
|
||||
raise ValidationError(
|
||||
'The module in the parameter "reuse_components_from" could not be found')
|
||||
|
||||
if reuse_module.state != models.BUILD_STATES["ready"]:
|
||||
raise ValidationError(
|
||||
'The module in the parameter "reuse_components_from" must be in the ready state'
|
||||
)
|
||||
|
||||
# Normalize the value so that it simplifies any code that uses this value
|
||||
self.data["reuse_components_from"] = reuse_module.id
|
||||
|
||||
|
||||
class SCMHandler(BaseHandler):
|
||||
def validate(self, skip_branch=False, skip_optional_params=False):
|
||||
|
||||
Reference in New Issue
Block a user