Skip to content

Commit 320ea9f

Browse files
committed
Make valid_build_images a @Property
1 parent 35665e5 commit 320ea9f

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

readthedocs/config/config.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,6 @@ class BuildConfigBase:
148148
'submodules',
149149
]
150150

151-
valid_build_images = {'stable', 'latest'}
152-
for k in DOCKER_IMAGE_SETTINGS:
153-
image, version = k.split(':')
154-
if re.fullmatch(r'^[\d\.]+$', version):
155-
valid_build_images.add(version)
156-
157151
default_build_image = DOCKER_DEFAULT_VERSION
158152
version = None
159153

@@ -255,6 +249,22 @@ def python_full_version(self):
255249
)
256250
return ver
257251

252+
@property
253+
def valid_build_images(self):
254+
"""
255+
Return all the valid Docker image choices for ``build.image`` option.
256+
257+
The user can use any of this values in the YAML file. These values are
258+
the keys of ``DOCKER_IMAGE_SETTINGS`` Django setting (without the
259+
``readthedocs/build`` part) plus ``stable`` and ``latest``.
260+
"""
261+
images = {'stable', 'latest'}
262+
for k in DOCKER_IMAGE_SETTINGS:
263+
image, version = k.split(':')
264+
if re.fullmatch(r'^[\d\.]+$', version):
265+
images.add(version)
266+
return images
267+
258268
def get_valid_python_versions_for_image(self, build_image):
259269
"""
260270
Return all the valid Python versions for a Docker image.

0 commit comments

Comments
 (0)