Skip to content

Commit

Permalink
Merge pull request #20 from pbortlov/deprecate-bundle
Browse files Browse the repository at this point in the history
Add deprecation_list and index_image_resolved attributes [CLOUDDST-3836]
  • Loading branch information
yashvardhannanavati committed Mar 29, 2021
2 parents 98e43b8 + 2066851 commit 4485cfe
Show file tree
Hide file tree
Showing 5 changed files with 75 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
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
3 changes: 3 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 All @@ -36,6 +37,7 @@ def setup_task(
"binary_image_resolved": binary_image + "-resolved",
"bundle_mapping": {},
"index_image": "feed.com/index/image:tag",
"index_image_resolved": "fake-example.com/index/image-resolved:tag",
"arches": arches,
"batch": 123,
"updated": "2020-05-26T19:33:58.759687Z",
Expand All @@ -44,6 +46,7 @@ def setup_task(
"organization": None,
"omps_operator_version": {},
"distribution_scope": "",
"deprecation_list": [] if not deprecation_list else deprecation_list,
}

if op_type == "rm":
Expand Down

0 comments on commit 4485cfe

Please sign in to comment.