From eae9175950c921cbd7995e4793b7c83561f342ec Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 1 Feb 2018 12:57:04 -0500 Subject: [PATCH] Allow size of pages in V2 api to be configurable --- config.py | 3 +++ endpoints/v2/__init__.py | 2 +- util/config/schema.py | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index 40426a1b4..43249828f 100644 --- a/config.py +++ b/config.py @@ -503,3 +503,6 @@ class DefaultConfig(ImmutableConfig): # Feature Flag: If enabled, users can create and use app specific tokens to login via the CLI. FEATURE_APP_SPECIFIC_TOKENS = True + + # The size of pages returned by the Docker V2 API. + V2_PAGINATION_SIZE = 50 diff --git a/endpoints/v2/__init__.py b/endpoints/v2/__init__.py index 28a837ddd..9b2b8cf67 100644 --- a/endpoints/v2/__init__.py +++ b/endpoints/v2/__init__.py @@ -41,7 +41,7 @@ def handle_registry_v2_exception(error): return response -_MAX_RESULTS_PER_PAGE = 50 +_MAX_RESULTS_PER_PAGE = app.config.get('V2_PAGINATION_SIZE', 50) def paginate(limit_kwarg_name='limit', offset_kwarg_name='offset', diff --git a/util/config/schema.py b/util/config/schema.py index 8af18dfa3..dca969ef5 100644 --- a/util/config/schema.py +++ b/util/config/schema.py @@ -383,6 +383,10 @@ CONFIG_SCHEMA = { 'description': 'The types of avatars to display, either generated inline (local) or Gravatar (gravatar)', 'enum': ['local', 'gravatar'], }, + 'V2_PAGINATION_SIZE': { + 'type': 'number', + 'description': 'The number of results returned per page in V2 registry APIs', + }, # Time machine and tag expiration settings. 'FEATURE_CHANGE_TAG_EXPIRATION': {