Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added build_tags attribute support #32

Merged
merged 2 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions legacy.constraints
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# These constraints are applied during testing with python2.
# Old versions of libraries can be added here if you want to
# ensure pubtools-quay works with those.
midnightercz marked this conversation as resolved.
Show resolved Hide resolved
PyYAML < 5.1
jsonschema==2.3.0
pluggy==0.5.2
pytest<3.7

# For compatibility with old pluggy
pytest-cov<2
10 changes: 10 additions & 0 deletions pubtools/iib/iib_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@
"required": False,
"type": bool,
},
("--build-tag",): {
"group": "IIB service",
"help": "extra tags to apply on built index image in temp namespace",
"required": False,
"type": str,
"action": "append",
},
}

ADD_CMD_ARGS = CMD_ARGS.copy()
Expand Down Expand Up @@ -237,6 +244,9 @@ def _iib_op_main(args, operation=None, items_final_state="PUSHED"):
if args.overwrite_from_index_token:
extra_args["overwrite_from_index_token"] = args.overwrite_from_index_token

if args.build_tag:
extra_args["build_tags"] = args.build_tag

build_details = bundle_op(
args.index_image,
args.bundle if operation == "add_bundles" else args.operator,
Expand Down
14 changes: 13 additions & 1 deletion tests/test_iib_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ def fixture_common_iib_op_args():
"example@REALM",
"--iib-insecure",
"--overwrite-from-index",
"--build-tag",
"extra-tag-1",
"--build-tag",
"extra-tag-2",
]


Expand All @@ -174,6 +178,7 @@ def add_bundles_mock_calls_tester(
overwrite_from_index=True,
overwrite_from_index_token="overwrite_from_index_token",
deprecation_list=["bundle1"],
build_tags=["extra-tag-1", "extra-tag-2"],
)
fixture_iib_client.assert_called_once_with(
"iib-server", auth=fixture_iib_krb_auth.return_value, ssl_verify=False
Expand All @@ -198,6 +203,7 @@ def add_bundles_mock_calls_tester_empty_deprecation_list(
binary_image="binary-image",
overwrite_from_index=True,
overwrite_from_index_token="overwrite_from_index_token",
build_tags=["extra-tag-1", "extra-tag-2"],
)
fixture_iib_client.assert_called_once_with(
"iib-server", auth=fixture_iib_krb_auth.return_value, ssl_verify=False
Expand All @@ -223,6 +229,7 @@ def add_bundles_mock_calls_tester_deprecation_bundles(
overwrite_from_index=True,
overwrite_from_index_token="overwrite_from_index_token",
deprecation_list=["bundle1", "bundle2"],
build_tags=["extra-tag-1", "extra-tag-2"],
)
fixture_iib_client.assert_called_once_with(
"iib-server", auth=fixture_iib_krb_auth.return_value, ssl_verify=False
Expand All @@ -247,6 +254,7 @@ def add_bundles_mock_calls_tester_not_called(
binary_image="binary-image",
overwrite_from_index=True,
overwrite_from_index_token="overwrite_from_index_token",
build_tags=["extra-tag-1", "extra-tag-2"],
)
fixture_iib_client.assert_called_once_with(
"iib-server", auth=fixture_iib_krb_auth.return_value, ssl_verify=False
Expand All @@ -271,6 +279,7 @@ def remove_operators_mock_calls_tester_not_called(
binary_image="binary-image",
overwrite_from_index=True,
overwrite_from_index_token="overwrite_from_index_token",
build_tags=["extra-tag-1", "extra-tag-2"],
)
fixture_pulplib_repo_sync.assert_not_called()
fixture_pulplib_repo_publish.assert_not_called()
Expand All @@ -292,6 +301,7 @@ def remove_operators_mock_calls_tester(
binary_image="binary-image",
overwrite_from_index=True,
overwrite_from_index_token="overwrite_from_index_token",
build_tags=["extra-tag-1", "extra-tag-2"],
)
fixture_pulplib_repo_sync.assert_called_once()
assert fixture_pulplib_repo_sync.mock_calls[0].args[0].feed == "https://feed.com"
Expand Down Expand Up @@ -451,6 +461,7 @@ def test_add_bundles_py(
binary_image="binary-image",
overwrite_from_index=True,
overwrite_from_index_token="overwrite_from_index_token",
build_tags=["extra-tag-1", "extra-tag-2"],
)
fixture_pulplib_repo_sync.assert_called_once()
assert fixture_pulplib_repo_sync.mock_calls[0].args[0].feed == "https://feed.com"
Expand All @@ -461,7 +472,7 @@ def test_add_bundles_py(
url_msg = "IIB details: https://{}/api/v1/builds/{}".format(
FIXTURE_IIB_SERVER, task_id
)
assert url_msg in caplog.messages
assert url_msg in [r.getMessage() for r in caplog.records]

# neither build details nor anything else dumped into stdout
captured = capsys.readouterr()
Expand Down Expand Up @@ -508,6 +519,7 @@ def test_add_bundles_py_multiple_bundles(
binary_image="binary-image",
overwrite_from_index=True,
overwrite_from_index_token="overwrite_from_index_token",
build_tags=["extra-tag-1", "extra-tag-2"],
)
fixture_pulplib_repo_sync.assert_called_once()
assert fixture_pulplib_repo_sync.mock_calls[0].args[0].feed == "https://feed.com"
Expand Down
1 change: 1 addition & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def setup_task(
state_seq=("in_progress", "finished"),
op_type="add",
deprecation_list=None,
build_tags=None,
):
tid = self._gen_task_id()
self.task_state_seq[tid] = list(state_seq)
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ exclude=.svn,CVS,.bzr,.hg,.git,__pycache__,.tox,setup.py,docs
[testenv:py27]
deps=
{[py]deps}
-c legacy.constraints
basepython = python2.7
commands = python -m pytest -v --cov=pubtools --cov-report=html

Expand Down