Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
release:gen-payload disallow multi with limited images
Browse files Browse the repository at this point in the history
  • Loading branch information
sosiouxme committed Sep 20, 2022
1 parent 16483cb commit 3242904
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
16 changes: 11 additions & 5 deletions doozerlib/cli/release_gen_payload.py
Expand Up @@ -284,17 +284,23 @@ def run(self):

def validate_parameters(self):
"""Sanity check the assembly requested and adjust state accordingly."""
assembly = self.runtime.assembly
if assembly not in {None, "stream", "test"} and assembly not in self.runtime.releases_config.releases:
raise DoozerFatalError(f"Assembly '{assembly}' is not explicitly defined.")
rt = self.runtime
if rt.assembly not in {None, "stream", "test"} and rt.assembly not in rt.releases_config.releases:
raise DoozerFatalError(f"Assembly '{rt.assembly}' is not explicitly defined.")

if assembly and assembly != "stream" and "art-latest" in self.base_imagestream[1]:
if rt.assembly and rt.assembly != "stream" and "art-latest" in self.base_imagestream[1]:
raise ValueError('"art-latest" imagestreams should only be used for the "stream" assembly')

if self.runtime.assembly_type is AssemblyTypes.STREAM:
if rt.assembly_type is AssemblyTypes.STREAM:
# Only nightlies have the concept of private and public payloads
self.privacy_modes = [False, True]

# check that we can produce a full multi nightly if requested
if self.apply_multi_arch and (rt.images or rt.exclude or self.exclude_arch):
raise DoozerFatalError(
"Cannot create a multi nightly without including the full set of images. "
"Either include all images/arches or omit --apply-multi-arch")

def generate_assembly_report(self, assembly_inspector: AssemblyInspector) -> Dict:
"""Generate a status report of the search for inconsistencies across all payloads generated."""
rt = self.runtime
Expand Down
10 changes: 10 additions & 0 deletions tests/cli/test_gen_payload.py
Expand Up @@ -78,6 +78,16 @@ def test_parameter_validation(self):
gpcli.validate_parameters()
self.assertIn(True, gpcli.privacy_modes, "stream assemblies should have private mode")

# and that we're protected against incomplete multi nightlies
gpcli = rgp_cli.GenPayloadCli(
apply_multi_arch=True,
runtime=MagicMock(
assembly="stream",
exclude=["some-random-image"],
))
with self.assertRaises(DoozerFatalError):
gpcli.validate_parameters()

@patch.object(AssemblyInspector, "__init__", lambda *_: None)
@patch.object(AssemblyInspector, "get_group_release_images", Mock(return_value={}))
@patch("doozerlib.cli.release_gen_payload.GenPayloadCli.generate_assembly_issues_report")
Expand Down

0 comments on commit 3242904

Please sign in to comment.