diff --git a/README.rst b/README.rst index 0095fbc..40a9724 100644 --- a/README.rst +++ b/README.rst @@ -43,6 +43,7 @@ Push the created index image to Pulp --bundle container-registry.example.com/bundle/image:123 --arch x86_64 --skip-quay + --deprecation-list container-registry.example.com/index/bundle-image:latest,container-registry.example.com/index/bundle-image:2 $ export PULP_PASSWORD="pulppassword" $ pubtools-iib-remove-operators --pulp-url https://pulphost.example.com/\ diff --git a/pubtools/iib/iib_ops.py b/pubtools/iib/iib_ops.py index 7a6b4b3..898a454 100644 --- a/pubtools/iib/iib_ops.py +++ b/pubtools/iib/iib_ops.py @@ -248,6 +248,12 @@ "required": False, "type": str, } +ADD_CMD_ARGS[("--deprecation-list",)] = { + "group": "IIB service", + "help": "Comma separated list of deprecated bundles", + "required": False, + "type": str, +} RM_CMD_ARGS = CMD_ARGS.copy() RM_CMD_ARGS[("--operator",)] = { @@ -529,6 +535,8 @@ def _iib_op_main(args, operation=None, items_final_state="PUSHED"): extra_args = {"cnr_token": args.iib_cnr_token} if args.iib_legacy_org: extra_args["organization"] = args.iib_legacy_org + if args.deprecation_list: + extra_args["deprecation_list"] = args.deprecation_list.split(",") if args.binary_image: extra_args["binary_image"] = args.binary_image diff --git a/setup.py b/setup.py index e942c83..728dff2 100644 --- a/setup.py +++ b/setup.py @@ -49,10 +49,12 @@ def read_content(filepath): "Programming Language :: Python :: Implementation :: PyPy", ] + def get_requirements(): with open("requirements.txt") as f: return f.read().splitlines() + DEPENDENCY_LINKS = [] diff --git a/tests/fake_task_manager.py b/tests/fake_task_manager.py index 55ed2bb..9b6e793 100644 --- a/tests/fake_task_manager.py +++ b/tests/fake_task_manager.py @@ -45,6 +45,7 @@ def setup_task( if op_type == "add": self.tasks[tid]["request_type"] = 1 self.tasks[tid]["bundle_mapping"] = {"operator-1": map_or_op} + self.tasks[tid]["deprecation_list"] = ["bundle1", "bundle2"] return self.tasks[tid] diff --git a/tests/test_iib_ops.py b/tests/test_iib_ops.py index aeb6a93..cb5a228 100644 --- a/tests/test_iib_ops.py +++ b/tests/test_iib_ops.py @@ -213,6 +213,56 @@ def add_bundles_mock_calls_tester( binary_image="binary-image", overwrite_from_index=True, overwrite_from_index_token="overwrite_from_index_token", + deprecation_list=["bundle1"], + ) + fixture_iib_client.assert_called_once_with( + "iib-server", auth=fixture_iib_krb_auth.return_value, ssl_verify=False + ) + fixture_pulplib_repo_sync.assert_called_once() + assert fixture_pulplib_repo_sync.mock_calls[0].args[0].feed == "https://feed.com" + fixture_pulplib_repo_publish.assert_called_once() + + +def add_bundles_mock_calls_tester_empty_deprecation_list( + fixture_iib_client, + fixture_pulplib_repo_sync, + fixture_pulplib_repo_publish, + fixture_iib_krb_auth, +): + fixture_iib_client.return_value.add_bundles.assert_called_once_with( + "index-image", + ["bundle1"], + ["arch"], + cnr_token="cnr_token", + organization="legacy-org", + binary_image="binary-image", + overwrite_from_index=True, + overwrite_from_index_token="overwrite_from_index_token", + ) + fixture_iib_client.assert_called_once_with( + "iib-server", auth=fixture_iib_krb_auth.return_value, ssl_verify=False + ) + fixture_pulplib_repo_sync.assert_called_once() + assert fixture_pulplib_repo_sync.mock_calls[0].args[0].feed == "https://feed.com" + fixture_pulplib_repo_publish.assert_called_once() + + +def add_bundles_mock_calls_tester_deprecation_bundles( + fixture_iib_client, + fixture_pulplib_repo_sync, + fixture_pulplib_repo_publish, + fixture_iib_krb_auth, +): + fixture_iib_client.return_value.add_bundles.assert_called_once_with( + "index-image", + ["bundle1"], + ["arch"], + cnr_token="cnr_token", + organization="legacy-org", + binary_image="binary-image", + overwrite_from_index=True, + overwrite_from_index_token="overwrite_from_index_token", + deprecation_list=["bundle1", "bundle2"], ) fixture_iib_client.assert_called_once_with( "iib-server", auth=fixture_iib_krb_auth.return_value, ssl_verify=False @@ -293,10 +343,20 @@ def remove_operators_mock_calls_tester( "extra_args,push_items,mock_calls_tester", [ ( - [], + ["--deprecation-list", "bundle1,bundle2"], + [operator_1_push_item_pending, operator_1_push_item_pushed], + add_bundles_mock_calls_tester_deprecation_bundles, + ), + ( + ["--deprecation-list", "bundle1"], [operator_1_push_item_pending, operator_1_push_item_pushed], add_bundles_mock_calls_tester, ), + ( + ["--deprecation-list", ""], + [operator_1_push_item_pending, operator_1_push_item_pushed], + add_bundles_mock_calls_tester_empty_deprecation_list, + ), ( ["--skip-pulp"], [operator_1_push_item_pending], diff --git a/tests/utils.py b/tests/utils.py index 0b29f9b..ea1e454 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -21,6 +21,7 @@ def setup_task( overwrite_from_index_token=None, state_seq=("in_progress", "finished"), op_type="add", + deprecation_list=None, ): tid = self._gen_task_id() self.task_state_seq[tid] = list(state_seq) @@ -51,6 +52,7 @@ def setup_task( if op_type == "add": self.tasks[tid]["request_type"] = "add" self.tasks[tid]["bundle_mapping"] = {"operator-1": map_or_op} + self.tasks[tid]["deprecation_list"] = deprecation_list return self.tasks[tid]