Skip to content

Commit daea301

Browse files
Adding RTD prefix for docker only and changing the variable names to pass all the tests
1 parent 93bcf8d commit daea301

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

readthedocs/config/config.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class BuildConfigBase:
151151
'submodules',
152152
]
153153

154-
default_build_image = settings.DOCKER_DEFAULT_VERSION
154+
default_build_image = settings.RTD_DOCKER_DEFAULT_VERSION
155155

156156
version = None
157157

@@ -266,7 +266,7 @@ def valid_build_images(self):
266266
``readthedocs/build`` part) plus ``stable`` and ``latest``.
267267
"""
268268
images = {'stable', 'latest'}
269-
for k in settings.DOCKER_IMAGE_SETTINGS:
269+
for k in settings.RTD_DOCKER_IMAGE_SETTINGS:
270270
_, version = k.split(':')
271271
if re.fullmatch(r'^[\d\.]+$', version):
272272
images.add(version)
@@ -282,12 +282,12 @@ def get_valid_python_versions_for_image(self, build_image):
282282
Returns supported versions for the ``DOCKER_DEFAULT_VERSION`` if not
283283
``build_image`` found.
284284
"""
285-
if build_image not in settings.DOCKER_IMAGE_SETTINGS:
285+
if build_image not in settings.RTD_DOCKER_IMAGE_SETTINGS:
286286
build_image = '{}:{}'.format(
287-
settings.DOCKER_DEFAULT_IMAGE,
287+
settings.RTD_DOCKER_DEFAULT_IMAGE,
288288
self.default_build_image,
289289
)
290-
return settings.DOCKER_IMAGE_SETTINGS[build_image]['python']['supported_versions']
290+
return settings.RTD_DOCKER_IMAGE_SETTINGS[build_image]['python']['supported_versions']
291291

292292
def as_dict(self):
293293
config = {}
@@ -324,7 +324,7 @@ def get_valid_python_versions(self):
324324
return self.env_config['python']['supported_versions']
325325
except (KeyError, TypeError):
326326
versions = set()
327-
for _, options in settings.DOCKER_IMAGE_SETTINGS.items():
327+
for _, options in settings.RTD_DOCKER_IMAGE_SETTINGS.items():
328328
versions = versions.union(
329329
options['python']['supported_versions']
330330
)
@@ -379,7 +379,7 @@ def validate_build(self):
379379
if 'build' in self.env_config:
380380
build = self.env_config['build'].copy()
381381
else:
382-
build = {'image': settings.DOCKER_IMAGE}
382+
build = {'image': settings.RTD_DOCKER_IMAGE}
383383

384384
# User specified
385385
if 'build' in self.raw_config:
@@ -393,12 +393,12 @@ def validate_build(self):
393393
if ':' not in build['image']:
394394
# Prepend proper image name to user's image name
395395
build['image'] = '{}:{}'.format(
396-
settings.DOCKER_DEFAULT_IMAGE,
396+
settings.RTD_DOCKER_DEFAULT_IMAGE,
397397
build['image'],
398398
)
399399
# Update docker default settings from image name
400-
if build['image'] in settings.DOCKER_IMAGE_SETTINGS:
401-
self.env_config.update(settings.DOCKER_IMAGE_SETTINGS[build['image']])
400+
if build['image'] in settings.RTD_DOCKER_IMAGE_SETTINGS:
401+
self.env_config.update(settings.RTD_DOCKER_IMAGE_SETTINGS[build['image']])
402402

403403
# Allow to override specific project
404404
config_image = self.defaults.get('build_image')
@@ -700,7 +700,7 @@ def validate_build(self):
700700
with self.catch_validation_error('build.image'):
701701
image = self.pop_config('build.image', self.default_build_image)
702702
build['image'] = '{}:{}'.format(
703-
settings.DOCKER_DEFAULT_IMAGE,
703+
settings.RTD_DOCKER_DEFAULT_IMAGE,
704704
validate_choice(
705705
image,
706706
self.valid_build_images,

readthedocs/doc_builder/constants.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313
PDF_RE = re.compile('Output written on (.*?)')
1414

1515
# Docker
16-
DOCKER_SOCKET = settings.DOCKER_SOCKET
17-
DOCKER_VERSION = settings.DOCKER_VERSION
18-
DOCKER_IMAGE = settings.DOCKER_IMAGE
19-
DOCKER_IMAGE_SETTINGS = settings.DOCKER_IMAGE_SETTINGS
16+
DOCKER_SOCKET = settings.RTD_DOCKER_SOCKET
17+
DOCKER_VERSION = settings.RTD_DOCKER_VERSION
18+
DOCKER_IMAGE = settings.RTD_DOCKER_IMAGE
19+
DOCKER_IMAGE_SETTINGS = settings.RTD_DOCKER_IMAGE_SETTINGS
2020

21-
old_config = settings.DOCKER_BUILD_IMAGES
21+
old_config = settings.RTD_DOCKER_BUILD_IMAGES
2222
if old_config:
2323
log.warning(
2424
'Old config detected, DOCKER_BUILD_IMAGES->DOCKER_IMAGE_SETTINGS',
2525
)
2626
DOCKER_IMAGE_SETTINGS.update(old_config)
2727

2828
DOCKER_LIMITS = {'memory': '200m', 'time': 600}
29-
DOCKER_LIMITS.update(settings.DOCKER_LIMITS)
29+
DOCKER_LIMITS.update(settings.RTD_DOCKER_LIMITS)
3030

3131
DOCKER_TIMEOUT_EXIT_CODE = 42
3232
DOCKER_OOM_EXIT_CODE = 137

readthedocs/projects/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ def repo_nonblockinglock(self, version, max_lock_age=None):
852852
if max_lock_age is None:
853853
max_lock_age = (
854854
self.container_time_limit or
855-
settings.DOCKER_LIMITS.get('time') or
855+
settings.RTD_DOCKER_LIMITS.get('time') or
856856
settings.REPO_LOCK_SECONDS
857857
)
858858

readthedocs/projects/tasks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def run(
380380
"""
381381
try:
382382
if docker is None:
383-
docker = settings.DOCKER_ENABLE
383+
docker = settings.RTD_DOCKER_ENABLE
384384
self.version = self.get_version(version_pk)
385385
self.project = self.version.project
386386
self.build = self.get_build(build_pk)

readthedocs/settings/base.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,16 @@ def USE_PROMOS(self): # noqa
335335
SENTRY_CELERY_IGNORE_EXPECTED = True
336336

337337
# Docker
338-
DOCKER_ENABLE = False
339-
DOCKER_SOCKET = 'unix:///var/run/docker.sock'
338+
RTD_DOCKER_ENABLE = False
339+
RTD_DOCKER_SOCKET = 'unix:///var/run/docker.sock'
340340
# This settings has been deprecated in favor of DOCKER_IMAGE_SETTINGS
341-
DOCKER_BUILD_IMAGES = None
342-
DOCKER_LIMITS = {'memory': '200m', 'time': 600}
343-
DOCKER_DEFAULT_IMAGE = 'readthedocs/build'
344-
DOCKER_VERSION = 'auto'
345-
DOCKER_DEFAULT_VERSION = 'latest'
346-
DOCKER_IMAGE = '{}:{}'.format(DOCKER_DEFAULT_IMAGE, DOCKER_DEFAULT_VERSION)
347-
DOCKER_IMAGE_SETTINGS = {
341+
RTD_DOCKER_BUILD_IMAGES = None
342+
RTD_DOCKER_LIMITS = {'memory': '200m', 'time': 600}
343+
RTD_DOCKER_DEFAULT_IMAGE = 'readthedocs/build'
344+
RTD_DOCKER_VERSION = 'auto'
345+
RTD_DOCKER_DEFAULT_VERSION = 'latest'
346+
RTD_DOCKER_IMAGE = '{}:{}'.format(RTD_DOCKER_DEFAULT_IMAGE, RTD_DOCKER_DEFAULT_VERSION)
347+
RTD_DOCKER_IMAGE_SETTINGS = {
348348
'readthedocs/build:1.0': {
349349
'python': {'supported_versions': [2, 2.7, 3, 3.4]},
350350
},
@@ -363,9 +363,9 @@ def USE_PROMOS(self): # noqa
363363
}
364364

365365
# Alias tagged via ``docker tag`` on the build servers
366-
DOCKER_IMAGE_SETTINGS.update({
367-
'readthedocs/build:stable': DOCKER_IMAGE_SETTINGS.get('readthedocs/build:4.0'),
368-
'readthedocs/build:latest': DOCKER_IMAGE_SETTINGS.get('readthedocs/build:5.0'),
366+
RTD_DOCKER_IMAGE_SETTINGS.update({
367+
'readthedocs/build:stable': RTD_DOCKER_IMAGE_SETTINGS.get('readthedocs/build:4.0'),
368+
'readthedocs/build:latest': RTD_DOCKER_IMAGE_SETTINGS.get('readthedocs/build:5.0'),
369369
})
370370

371371
# All auth

0 commit comments

Comments
 (0)