Skip to content

Commit

Permalink
Make valid_build_images a @Property
Browse files Browse the repository at this point in the history
  • Loading branch information
humitos committed Jan 23, 2019
1 parent 35665e5 commit 320ea9f
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions readthedocs/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 320ea9f

Please sign in to comment.