Skip to content

Commit

Permalink
Add deprecation list attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
pbortlov committed Mar 23, 2021
1 parent 98e43b8 commit 9567534
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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/\
Expand Down
8 changes: 8 additions & 0 deletions pubtools/iib/iib_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",)] = {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []


Expand Down
3 changes: 3 additions & 0 deletions tests/fake_task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def setup_task(
binary_image="binary-image",
state_seq=("in_progress", "finished"),
op_type="add",
deprecation_list=None,

):
tid = self._gen_task_id()
self.task_state_seq[tid] = list(state_seq)
Expand Down Expand Up @@ -45,6 +47,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"] = deprecation_list

return self.tasks[tid]

Expand Down
62 changes: 61 additions & 1 deletion tests/test_iib_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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],
Expand Down
2 changes: 2 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]

Expand Down

0 comments on commit 9567534

Please sign in to comment.