Skip to content

Commit 9c2e15f

Browse files
committed
Add Index Catalog to GitLab push configuration
This commit introduces a new API configuration named `IIB_INDEX_TO_GITLAB_PUSH_MAP`, which may contain a mapping between index images (keys) to push its catalogs into certain GitLab repositories (values). The implementation of GitLab push will be added into a different PR. Refers to CLOUDDST-26435 Signed-off-by: Jonathan Gangi <jgangi@redhat.com>
1 parent e8fd5d6 commit 9c2e15f

6 files changed

Lines changed: 25 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ The custom configuration options for the REST API are listed below:
199199
to another dictionary mapping ocp_version label to a binary image pull specification.
200200
This is useful in setting up customized binary image for different index image images thus
201201
reducing complexity for the end user. This defaults to `{}`.
202+
* `IIB_INDEX_TO_GITLAB_PUSH_MAP` - the mapping, `dict(<str>:<str>)`, to specify which index
203+
images (keys) which should have its catalog pushed into a GitLab repository (value). This defaults to {}.
202204
* `IIB_GRAPH_MODE_INDEX_ALLOW_LIST` - the list of index image pull specs on which using the
203205
`graph_update_mode` parameter while submitting an IIB request is permitted. This defaults to `[]`
204206
. Please check out the [API Documentation](http://release-engineering.github.io/iib) for more

iib/web/api_v1.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def _get_rm_args(
9999
request.distribution_scope,
100100
flask.current_app.config['IIB_BINARY_IMAGE_CONFIG'],
101101
payload.get('build_tags', []),
102+
flask.current_app.config['IIB_INDEX_TO_GITLAB_PUSH_MAP'],
102103
]
103104

104105

@@ -136,6 +137,7 @@ def _get_add_args(
136137
payload.get('build_tags', []),
137138
payload.get('graph_update_mode'),
138139
payload.get('check_related_images', False),
140+
flask.current_app.config['IIB_INDEX_TO_GITLAB_PUSH_MAP'],
139141
]
140142

141143

@@ -750,6 +752,7 @@ def patch_request(request_id: int) -> Tuple[flask.Response, int]:
750752
'parent_bundle_image_resolved',
751753
'source_from_index_resolved',
752754
'target_index_resolved',
755+
'index_to_gitlab_push_map',
753756
)
754757
start_time = time.time()
755758
for key in image_keys:
@@ -1315,6 +1318,7 @@ def fbc_operations() -> Tuple[flask.Response, int]:
13151318
payload.get('build_tags'),
13161319
payload.get('add_arches'),
13171320
flask.current_app.config['IIB_BINARY_IMAGE_CONFIG'],
1321+
flask.current_app.config['IIB_INDEX_TO_GITLAB_PUSH_MAP'],
13181322
]
13191323
safe_args = _get_safe_args(args, payload)
13201324
error_callback = failed_request_callback.s(request.id)

iib/web/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Config(object):
2020
IIB_ADDITIONAL_LOGGERS: List[str] = []
2121
IIB_AWS_S3_BUCKET_NAME: Optional[str] = None
2222
IIB_BINARY_IMAGE_CONFIG: Dict[str, Dict[str, str]] = {}
23+
IIB_INDEX_TO_GITLAB_PUSH_MAP: Dict[str, str] = {}
2324
IIB_GRAPH_MODE_INDEX_ALLOW_LIST: List[str] = []
2425
IIB_GRAPH_MODE_OPTIONS: List[str] = ['replaces', 'semver', 'semver-skippatch']
2526
IIB_GREENWAVE_CONFIG: Dict[str, str] = {}

iib/workers/tasks/build.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,7 @@ def handle_add_request(
723723
build_tags: Optional[List[str]] = None,
724724
graph_update_mode: Optional[str] = None,
725725
check_related_images: bool = False,
726+
index_to_gitlab_push_map: Optional[Dict[str, str]] = None,
726727
username: Optional[str] = None,
727728
traceparent: Optional[str] = None,
728729
) -> None:
@@ -761,6 +762,8 @@ def handle_add_request(
761762
:param list build_tags: List of tags which will be applied to intermediate index images.
762763
:param str graph_update_mode: Graph update mode that defines how channel graphs are updated
763764
in the index.
765+
:param dict index_to_gitlab_push_map: the dict mapping index images (keys) to GitLab repos
766+
(values) in order to push their catalogs into GitLab.
764767
:param str traceparent: the traceparent header value to be used for tracing the request.
765768
:raises IIBError: if the index image build fails.
766769
"""
@@ -1012,6 +1015,7 @@ def handle_rm_request(
10121015
distribution_scope: Optional[str] = None,
10131016
binary_image_config: Optional[Dict[str, Dict[str, str]]] = None,
10141017
build_tags: Optional[List[str]] = None,
1018+
index_to_gitlab_push_map: Optional[Dict[str, str]] = None,
10151019
) -> None:
10161020
"""
10171021
Coordinate the work needed to remove the input operators and rebuild the index image.
@@ -1035,6 +1039,8 @@ def handle_rm_request(
10351039
:param dict binary_image_config: the dict of config required to identify the appropriate
10361040
``binary_image`` to use.
10371041
:param list build_tags: List of tags which will be applied to intermediate index images.
1042+
:param dict index_to_gitlab_push_map: the dict mapping index images (keys) to GitLab repos
1043+
(values) in order to remove their catalogs from GitLab.
10381044
:raises IIBError: if the index image build fails.
10391045
"""
10401046
_cleanup()

iib/workers/tasks/build_fbc_operations.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def handle_fbc_operation_request(
4646
build_tags: Optional[Set[str]] = None,
4747
add_arches: Optional[Set[str]] = None,
4848
binary_image_config: Optional[Dict[str, Dict[str, str]]] = None,
49+
index_to_gitlab_push_map: Optional[Dict[str, str]] = None,
4950
) -> None:
5051
"""
5152
Add a fbc fragment to an fbc index image.
@@ -59,6 +60,8 @@ def handle_fbc_operation_request(
5960
:param set add_arches: the set of arches to build in addition to the arches ``from_index`` is
6061
currently built for; if ``from_index`` is ``None``, then this is used as the list of arches
6162
to build the index image for
63+
:param dict index_to_gitlab_push_map: the dict mapping index images (keys) to GitLab repos
64+
(values) in order to push their catalogs into GitLab.
6265
"""
6366
_cleanup()
6467
set_request_state(request_id, 'in_progress', 'Resolving the fbc fragment')

tests/test_web/test_api_v1.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -959,9 +959,9 @@ def test_add_bundle_overwrite_token_redacted(mock_smfsc, mock_har, app, auth_env
959959
assert rv.status_code == 201
960960
mock_har.apply_async.assert_called_once()
961961
# Tenth to last element in args is the overwrite_from_index parameter
962-
assert mock_har.apply_async.call_args[1]['args'][-10] is True
962+
assert mock_har.apply_async.call_args[1]['args'][-11] is True
963963
# Ninth to last element in args is the overwrite_from_index_token parameter
964-
assert mock_har.apply_async.call_args[1]['args'][-9] == token
964+
assert mock_har.apply_async.call_args[1]['args'][-10] == token
965965
assert 'overwrite_from_index_token' not in rv_json
966966
assert token not in json.dumps(rv_json)
967967
assert token not in mock_har.apply_async.call_args[1]['argsrepr']
@@ -1492,8 +1492,8 @@ def test_remove_operator_overwrite_token_redacted(mock_smfsc, mock_hrr, app, aut
14921492
assert rv.status_code == 201
14931493
mock_hrr.apply_async.assert_called_once()
14941494
# Third to last element in args is the overwrite_from_index parameter
1495-
assert mock_hrr.apply_async.call_args[1]['args'][-5] is True
1496-
assert mock_hrr.apply_async.call_args[1]['args'][-4] == token
1495+
assert mock_hrr.apply_async.call_args[1]['args'][-6] is True
1496+
assert mock_hrr.apply_async.call_args[1]['args'][-5] == token
14971497
assert 'overwrite_from_index_token' not in rv_json
14981498
assert token not in json.dumps(rv_json)
14991499
assert token not in mock_hrr.apply_async.call_args[1]['argsrepr']
@@ -1858,12 +1858,14 @@ def test_add_rm_batch_success(mock_smfnbor, mock_hrr, mock_har, app, auth_env, c
18581858
[],
18591859
None,
18601860
False,
1861+
{},
18611862
],
18621863
argsrepr=(
18631864
"[['registry-proxy/rh-osbs/lgallett-bundle:v1.0-9'], "
18641865
"1, 'registry-proxy/rh-osbs/openshift-ose-operator-registry:v4.5', "
18651866
"'registry-proxy/rh-osbs-stage/iib:v4.5', ['amd64'], '*****', "
1866-
"'hello-operator', None, True, '*****', None, None, {}, [], [], None, False]"
1867+
"'hello-operator', None, True, '*****', None, None, {}, [], [], None, "
1868+
"False, {}]"
18671869
),
18681870
link_error=mock.ANY,
18691871
queue=None,
@@ -1884,11 +1886,12 @@ def test_add_rm_batch_success(mock_smfnbor, mock_hrr, mock_har, app, auth_env, c
18841886
None,
18851887
{},
18861888
[],
1889+
{},
18871890
],
18881891
argsrepr=(
18891892
"[['kiali-ossm'], 2, 'registry:8443/iib-build:11', "
18901893
"'registry-proxy/rh-osbs/openshift-ose-operator-registry:v4.5'"
1891-
", None, False, None, None, {}, []]"
1894+
", None, False, None, None, {}, [], {}]"
18921895
),
18931896
link_error=mock.ANY,
18941897
queue=None,

0 commit comments

Comments
 (0)