diff --git a/bodhi-server/bodhi/server/__init__.py b/bodhi-server/bodhi/server/__init__.py index 6df7ef0449..77d20c9b9a 100644 --- a/bodhi-server/bodhi/server/__init__.py +++ b/bodhi-server/bodhi/server/__init__.py @@ -297,6 +297,9 @@ def main(global_config, testing=None, session=None, **settings): config.add_route('liveness', '/healthz/live') config.add_route('readyness', '/healthz/ready') + # service endpoints + config.add_route('get_critpath_components', '/get_critpath_components') + # Legacy: Redirect the previously self-hosted documentation # https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/hybrid.html#using-subpath-in-a-route-pattern config.add_route("docs", "/docs/*subpath") diff --git a/bodhi-server/bodhi/server/views/generic.py b/bodhi-server/bodhi/server/views/generic.py index b593ee2614..ac06f35408 100644 --- a/bodhi-server/bodhi/server/views/generic.py +++ b/bodhi-server/bodhi/server/views/generic.py @@ -622,3 +622,22 @@ def docs(request): subpath = "/".join(request.subpath) url = f"https://fedora-infra.github.io/bodhi/{major_minor_version}/{subpath}" raise HTTPMovedPermanently(url) + + +@view_config(route_name='get_critpath_components', renderer='json') +def get_critpath_components(request): + """ + Return critical path components configured in bodhi. + + Args: + request (pyramid.request.Request): The current request. + Returns: + dict: A dictionary with a "version" key indexing a string of the Bodhi version. + """ + collection = request.params.get('collection', 'master') + component_type = request.params.get('component_type', 'rpm') + components = request.params.get('components') + if components is not None: + components = components.split(',') + return bodhi.server.util.get_grouped_critpath_components(collection, component_type, + components)