Accept numbered versions for V1 and named ones for V2
V1 reads the versions from DOCKER_IMAGE_SETTINGS and keeps only the
numbered ones.
V2 only accepts `stable` and `latest` (they are hardcoded because they
don't change).
import copy
import os
+import re
from contextlib import contextmanager
from django.conf import settings
@@ -146,7 +147,6 @@ class BuildConfigBase:
'mkdocs',
'submodules',
]
- valid_build_images = [k.split(':')[1] for k in DOCKER_IMAGE_SETTINGS]
default_build_image = DOCKER_DEFAULT_VERSION
version = None
@@ -288,6 +288,13 @@ class BuildConfigV1(BuildConfigBase):
'"python.extra_requirements" section must be a list.'
)
+ # ConfigV1 accepts only numbered versions
+ valid_build_images = set()
+ for k in DOCKER_IMAGE_SETTINGS:
+ image, version = k.split(':')
+ if re.fullmatch(r'[\d\.]+', version):
+ valid_build_images.add(version)
+
version = '1'
def get_valid_python_versions(self):
@@ -610,6 +617,9 @@ class BuildConfigV2(BuildConfigBase):
}
builders_display = dict(DOCUMENTATION_CHOICES)
+ # Config V2 only accepts named versions
+ valid_build_images = ['stable', 'latest']
+
def validate(self):
"""
Validates and process ``raw_config`` and ``env_config``.
