From 320ea9f552458a7c1ae17f1969c428c5ce33099b Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 23 Jan 2019 19:04:14 +0100 Subject: [PATCH] Make valid_build_images a @property --- readthedocs/config/config.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/readthedocs/config/config.py b/readthedocs/config/config.py index 109410ea5fb..7c686614d98 100644 --- a/readthedocs/config/config.py +++ b/readthedocs/config/config.py @@ -148,12 +148,6 @@ class BuildConfigBase: 'submodules', ] - valid_build_images = {'stable', 'latest'} - for k in DOCKER_IMAGE_SETTINGS: - image, version = k.split(':') - if re.fullmatch(r'^[\d\.]+$', version): - valid_build_images.add(version) - default_build_image = DOCKER_DEFAULT_VERSION version = None @@ -255,6 +249,22 @@ def python_full_version(self): ) return ver + @property + def valid_build_images(self): + """ + Return all the valid Docker image choices for ``build.image`` option. + + The user can use any of this values in the YAML file. These values are + the keys of ``DOCKER_IMAGE_SETTINGS`` Django setting (without the + ``readthedocs/build`` part) plus ``stable`` and ``latest``. + """ + images = {'stable', 'latest'} + for k in DOCKER_IMAGE_SETTINGS: + image, version = k.split(':') + if re.fullmatch(r'^[\d\.]+$', version): + images.add(version) + return images + def get_valid_python_versions_for_image(self, build_image): """ Return all the valid Python versions for a Docker image.