diff --git a/pipeline.py b/pipeline.py index f33f85d1e..9afe29814 100755 --- a/pipeline.py +++ b/pipeline.py @@ -1518,40 +1518,13 @@ def build_all_images( build_image(image, build_configuration) -def calculate_images_to_build( - images: List[str], include: Optional[List[str]], exclude: Optional[List[str]] -) -> Set[str]: - """ - Calculates which images to build based on the `images`, `include` and `exclude` sets. - - >>> calculate_images_to_build(["a", "b"], ["a"], ["b"]) - ... ["a"] - """ - - if not include and not exclude: - return set(images) - include = set(include or []) - exclude = set(exclude or []) - images = set(images or []) - - for image in include.union(exclude): - if image not in images: - raise ValueError("Image definition {} not found".format(image)) - - images_to_build = include.intersection(images) - if exclude: - images_to_build = images.difference(exclude) - return images_to_build - - def main(): _setup_tracing() _setup_tracing() parser = argparse.ArgumentParser() - parser.add_argument("--include", action="append", help="list of images to include") - parser.add_argument("--exclude", action="append", help="list of images to exclude") - parser.add_argument("--builder", default="docker", type=str, help="docker or podman") + parser.add_argument("--include", help="list of images to include") + parser.add_argument("--builder", default="docker", type=str) parser.add_argument("--list-images", action="store_true") parser.add_argument("--parallel", action="store_true", default=False) parser.add_argument("--debug", action="store_true", default=False) @@ -1588,12 +1561,17 @@ def main(): if not args.sign: logger.warning("--sign flag not provided, images won't be signed") - images_to_build = calculate_images_to_build( - list(get_builder_function_for_image_name().keys()), args.include, args.exclude - ) + if args.include is None: + print("No images to build, --include is required.") + sys.exit(1) + + image_to_build = args.include + if args.include not in get_builder_function_for_image_name(): + print("Image {} not found".format(args.include)) + sys.exit(1) build_all_images( - images_to_build, + image_to_build, args.builder, debug=args.debug, parallel=args.parallel, diff --git a/pipeline_test.py b/pipeline_test.py index 68b7e3a8e..399bfad37 100644 --- a/pipeline_test.py +++ b/pipeline_test.py @@ -6,7 +6,6 @@ import pytest from pipeline import ( - calculate_images_to_build, gather_all_supported_agent_versions, gather_latest_agent_versions, get_versions_to_rebuild, @@ -64,58 +63,6 @@ def test_operator_build_configuration_defaults(): assert config.namespace == "default" -@pytest.mark.parametrize( - "test_case", - [ - (["a", "b", "c"], ["a"], ["b"], {"a", "c"}), - (["a", "b", "c"], ["a", "b"], None, {"a", "b"}), - (["a", "b", "c"], None, ["a"], {"b", "c"}), - (["a", "b", "c"], [], [], {"a", "b", "c"}), - (["a", "b", "c"], ["d"], None, ValueError), - (["a", "b", "c"], None, ["d"], ValueError), - ([], ["a"], ["b"], ValueError), - (["a", "b", "c"], None, None, {"a", "b", "c"}), - # Given an include, it should only return include images - (["cli", "ops-manager", "appdb-daily", "init-appdb"], ["cli"], [], {"cli"}), - # Given no include nor excludes it should return all images - ( - ["cli", "ops-manager", "appdb-daily", "init-appdb"], - [], - [], - {"init-appdb", "appdb-daily", "ops-manager", "cli"}, - ), - # Given an exclude, it should return all images except the excluded ones - ( - ["cli", "ops-manager", "appdb-daily", "init-appdb"], - [], - ["init-appdb", "appdb-daily"], - {"ops-manager", "cli"}, - ), - # Given an include and a different exclude, it should return all images except the exclusions - ( - ["cli", "ops-manager", "appdb-daily", "init-appdb"], - ["appdb-daily"], - ["init-appdb"], - {"appdb-daily", "cli", "ops-manager"}, - ), - # Given multiple includes and a different exclude, it should return all images except the exclusions - ( - ["cli", "ops-manager", "appdb-daily", "init-appdb"], - ["cli", "appdb-daily"], - ["init-appdb"], - {"appdb-daily", "cli", "ops-manager"}, - ), - ], -) -def test_calculate_images_to_build(test_case): - images, include, exclude, expected = test_case - if expected is ValueError: - with pytest.raises(ValueError): - calculate_images_to_build(images, include, exclude) - else: - assert calculate_images_to_build(images, include, exclude) == expected - - @pytest.mark.parametrize( "version,min_version,max_version,expected", [