From 827182be2b2c759e3cb57914252491f8524c396d Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Thu, 30 Nov 2017 11:49:18 -0800 Subject: [PATCH 01/14] Add the ability to add a docker config image --- docs/spec.rst | 6 +++++ readthedocs_build/config/config.py | 14 ++++++++++ readthedocs_build/config/test_config.py | 35 +++++++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/docs/spec.rst b/docs/spec.rst index c452a6b..1aa5c93 100644 --- a/docs/spec.rst +++ b/docs/spec.rst @@ -105,6 +105,12 @@ Following mapping keys are supported (all but the marked once are optional): - ``pdf``, default: ``false`` - ``epub``, default: ``false`` +``docker`` + Options for setting the docker configuration. + + ``image`` + This sets the docker image to use on the build, as defined `here `_. + ``python`` Python specific configuration. All builds are executed inside a virtualenv. This config can customize the virtualenv before running the diff --git a/readthedocs_build/config/config.py b/readthedocs_build/config/config.py index 625fdd3..d842e56 100644 --- a/readthedocs_build/config/config.py +++ b/readthedocs_build/config/config.py @@ -79,6 +79,7 @@ class BuildConfig(dict): '"python.extra_requirements" section must be a list.') PYTHON_SUPPORTED_VERSIONS = [2, 2.7, 3, 3.3, 3.4, 3.5, 3.6] + DOCKER_SUPPORTED_VERSIONS = ['1.0', '2.0', 'latest'] def __init__(self, env_config, raw_config, source_file, source_position): self.env_config = env_config @@ -205,6 +206,19 @@ def validate_base(self): base = validate_directory(base, base_path) self['base'] = base + def validate_docker(self): + # Defaults + docker = {'image': '2.0'} + if 'docker' in self.raw_config: + _docker = self.raw_config['docker'] + if 'image' in _docker: + with self.catch_validation_error('docker'): + docker['image'] = validate_choice( + str(_docker['image']), + self.DOCKER_SUPPORTED_VERSIONS, + ) + self['docker'] = docker + def validate_python(self): python = { 'use_system_site_packages': False, diff --git a/readthedocs_build/config/test_config.py b/readthedocs_build/config/test_config.py index af12be8..373c6ac 100644 --- a/readthedocs_build/config/test_config.py +++ b/readthedocs_build/config/test_config.py @@ -413,6 +413,41 @@ def it_fails_if_base_does_not_exist(tmpdir): assert excinfo.value.code == INVALID_PATH +def describe_validate_docker(): + + def it_fails_if_docker_is_invalid_option(tmpdir): + apply_fs(tmpdir, minimal_config) + build = BuildConfig( + {}, + {'docker': {'image': 3.0}}, + source_file=str(tmpdir.join('readthedocs.yml')), + source_position=0) + with raises(InvalidConfig) as excinfo: + build.validate_docker() + assert excinfo.value.key == 'docker' + assert excinfo.value.code == INVALID_CHOICE + + def it_works(tmpdir): + apply_fs(tmpdir, minimal_config) + build = BuildConfig( + {}, + {'docker': {'image': 'latest'}}, + source_file=str(tmpdir.join('readthedocs.yml')), + source_position=0) + build.validate_docker() + assert build['docker']['image'] == 'latest' + + def default(tmpdir): + apply_fs(tmpdir, minimal_config) + build = BuildConfig( + {}, + {}, + source_file=str(tmpdir.join('readthedocs.yml')), + source_position=0) + build.validate_docker() + assert build['docker']['image'] == '2.0' + + def test_build_validate_calls_all_subvalidators(tmpdir): apply_fs(tmpdir, minimal_config) build = BuildConfig( From 2db1cec5cc3758fa48a6ca2ecd6714403a8211b4 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Thu, 30 Nov 2017 12:42:09 -0800 Subject: [PATCH 02/14] Support docker and python validation in the rtd build configs --- docs/spec.rst | 2 +- readthedocs_build/config/config.py | 55 ++++++++++++--------- readthedocs_build/config/test_config.py | 66 +++++++++++++++---------- 3 files changed, 72 insertions(+), 51 deletions(-) diff --git a/docs/spec.rst b/docs/spec.rst index 1aa5c93..925e131 100644 --- a/docs/spec.rst +++ b/docs/spec.rst @@ -105,7 +105,7 @@ Following mapping keys are supported (all but the marked once are optional): - ``pdf``, default: ``false`` - ``epub``, default: ``false`` -``docker`` +``build`` Options for setting the docker configuration. ``image`` diff --git a/readthedocs_build/config/config.py b/readthedocs_build/config/config.py index d842e56..fe9bdd9 100644 --- a/readthedocs_build/config/config.py +++ b/readthedocs_build/config/config.py @@ -5,12 +5,8 @@ from .find import find_one from .parser import ParseError from .parser import parse -from .validation import validate_bool -from .validation import validate_choice -from .validation import validate_directory -from .validation import validate_file -from .validation import validate_string -from .validation import ValidationError +from .validation import (validate_bool, validate_choice, validate_directory, + validate_file, validate_string, ValidationError) __all__ = ( @@ -30,6 +26,18 @@ TYPE_REQUIRED = 'type-required' PYTHON_INVALID = 'python-invalid' +DOCKER_BUILD_IMAGES = { + '1.0': { + 'python': {'supported_versions': [2, 2.7, 3, 3.4]}, + }, + '2.0': { + 'python': {'supported_versions': [2, 2.7, 3, 3.5]}, + }, + 'latest': { + 'python': {'supported_versions': [2, 2.7, 3, 3.3, 3.4, 3.5, 3.6]}, + }, +} + class ConfigError(Exception): @@ -116,13 +124,6 @@ def get_valid_types(self): 'sphinx', ) - def get_valid_python_versions(self): - try: - return self.env_config['python']['supported_versions'] - except (KeyError, TypeError): - pass - return self.PYTHON_SUPPORTED_VERSIONS - def get_valid_formats(self): return ( 'none', @@ -146,6 +147,9 @@ def validate(self): # Validate env_config. self.validate_output_base() + # Validate the build environment first + self.validate_build() # Must happen before `validate_python`! + # Validate raw_config. Order matters. self.validate_name() self.validate_type() @@ -206,18 +210,23 @@ def validate_base(self): base = validate_directory(base, base_path) self['base'] = base - def validate_docker(self): + def validate_build(self): # Defaults - docker = {'image': '2.0'} - if 'docker' in self.raw_config: - _docker = self.raw_config['docker'] - if 'image' in _docker: - with self.catch_validation_error('docker'): - docker['image'] = validate_choice( - str(_docker['image']), + build = {'image': '2.0'} + if 'build' in self.raw_config: + _build = self.raw_config['build'] + if 'image' in _build: + with self.catch_validation_error('build'): + build['image'] = validate_choice( + str(_build['image']), self.DOCKER_SUPPORTED_VERSIONS, ) - self['docker'] = docker + self['build'] = build + + # Set the valid python versions for this container + + self.PYTHON_SUPPORTED_VERSIONS = \ + DOCKER_BUILD_IMAGES[build['image']]['python']['supported_versions'] def validate_python(self): python = { @@ -294,7 +303,7 @@ def validate_python(self): pass python['version'] = validate_choice( version, - self.get_valid_python_versions() + self.PYTHON_SUPPORTED_VERSIONS ) self['python'] = python diff --git a/readthedocs_build/config/test_config.py b/readthedocs_build/config/test_config.py index 373c6ac..b83fe7a 100644 --- a/readthedocs_build/config/test_config.py +++ b/readthedocs_build/config/test_config.py @@ -281,23 +281,6 @@ def it_validates_wrong_type_right_value(): build.validate_python() assert build['python']['version'] == 3 - def it_validates_env_supported_versions(): - build = get_build_config( - {'python': {'version': 3.6}}, - env_config={'python': {'supported_versions': [3.5]}} - ) - with raises(InvalidConfig) as excinfo: - build.validate_python() - assert excinfo.value.key == 'python.version' - assert excinfo.value.code == INVALID_CHOICE - - build = get_build_config( - {'python': {'version': 3.6}}, - env_config={'python': {'supported_versions': [3.5, 3.6]}} - ) - build.validate_python() - assert build['python']['version'] == 3.6 - def describe_validate_formats(): @@ -413,29 +396,58 @@ def it_fails_if_base_does_not_exist(tmpdir): assert excinfo.value.code == INVALID_PATH -def describe_validate_docker(): +def describe_validate_build(): - def it_fails_if_docker_is_invalid_option(tmpdir): + def it_fails_if_build_is_invalid_option(tmpdir): apply_fs(tmpdir, minimal_config) build = BuildConfig( {}, - {'docker': {'image': 3.0}}, + {'build': {'image': 3.0}}, source_file=str(tmpdir.join('readthedocs.yml')), source_position=0) with raises(InvalidConfig) as excinfo: - build.validate_docker() - assert excinfo.value.key == 'docker' + build.validate_build() + assert excinfo.value.key == 'build' assert excinfo.value.code == INVALID_CHOICE + def it_fails_on_python_validation(tmpdir): + apply_fs(tmpdir, minimal_config) + build = BuildConfig( + {}, + { + 'build': {'image': 1.0}, + 'python': {'version': '3.3'}, + }, + source_file=str(tmpdir.join('readthedocs.yml')), + source_position=0) + build.validate_build() + with raises(InvalidConfig) as excinfo: + build.validate_python() + assert excinfo.value.key == 'python.version' + assert excinfo.value.code == INVALID_CHOICE + + def it_works_on_python_validation(tmpdir): + apply_fs(tmpdir, minimal_config) + build = BuildConfig( + {}, + { + 'build': {'image': 'latest'}, + 'python': {'version': '3.3'}, + }, + source_file=str(tmpdir.join('readthedocs.yml')), + source_position=0) + build.validate_build() + build.validate_python() + def it_works(tmpdir): apply_fs(tmpdir, minimal_config) build = BuildConfig( {}, - {'docker': {'image': 'latest'}}, + {'build': {'image': 'latest'}}, source_file=str(tmpdir.join('readthedocs.yml')), source_position=0) - build.validate_docker() - assert build['docker']['image'] == 'latest' + build.validate_build() + assert build['build']['image'] == 'latest' def default(tmpdir): apply_fs(tmpdir, minimal_config) @@ -444,8 +456,8 @@ def default(tmpdir): {}, source_file=str(tmpdir.join('readthedocs.yml')), source_position=0) - build.validate_docker() - assert build['docker']['image'] == '2.0' + build.validate_build() + assert build['build']['image'] == '2.0' def test_build_validate_calls_all_subvalidators(tmpdir): From 9f17586d87a0d1abe1ff444c97a12499a965551f Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Thu, 30 Nov 2017 12:59:55 -0800 Subject: [PATCH 03/14] Clean up line --- readthedocs_build/config/config.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/readthedocs_build/config/config.py b/readthedocs_build/config/config.py index fe9bdd9..29da0f6 100644 --- a/readthedocs_build/config/config.py +++ b/readthedocs_build/config/config.py @@ -224,9 +224,8 @@ def validate_build(self): self['build'] = build # Set the valid python versions for this container - - self.PYTHON_SUPPORTED_VERSIONS = \ - DOCKER_BUILD_IMAGES[build['image']]['python']['supported_versions'] + img = build['image'] + self.PYTHON_SUPPORTED_VERSIONS = DOCKER_BUILD_IMAGES[img]['python']['supported_versions'] def validate_python(self): python = { From d766f41faf2ec24ed89786bacaae30c421b1a6c1 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Thu, 30 Nov 2017 13:38:05 -0800 Subject: [PATCH 04/14] pin pytest-describe --- requirements/tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/tests.txt b/requirements/tests.txt index 9a2ccdc..ded3e0f 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -1,5 +1,5 @@ mock==1.3.0 pytest>=2.7 -pytest-describe>=0.10.1 +pytest-describe==0.11.0 pytest-xdist>=1.12 tox>=2.1 From d93c81c1c6dc57633c7d407587d2695b168f1238 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Thu, 30 Nov 2017 13:39:30 -0800 Subject: [PATCH 05/14] Pin pytest --- requirements/tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/tests.txt b/requirements/tests.txt index ded3e0f..a9fc582 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -1,5 +1,5 @@ mock==1.3.0 -pytest>=2.7 +pytest==3.2.5 pytest-describe==0.11.0 pytest-xdist>=1.12 tox>=2.1 From 4d8537d18cc2428160d94dded770efa4708141bf Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Tue, 5 Dec 2017 10:43:20 -0800 Subject: [PATCH 06/14] Small cleanup --- docs/spec.rst | 2 +- readthedocs_build/config/config.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/spec.rst b/docs/spec.rst index 925e131..810a120 100644 --- a/docs/spec.rst +++ b/docs/spec.rst @@ -109,7 +109,7 @@ Following mapping keys are supported (all but the marked once are optional): Options for setting the docker configuration. ``image`` - This sets the docker image to use on the build, as defined `here `_. + This sets the build image to use on the build, as defined `here `_. ``python`` Python specific configuration. All builds are executed inside a diff --git a/readthedocs_build/config/config.py b/readthedocs_build/config/config.py index 29da0f6..2475dc3 100644 --- a/readthedocs_build/config/config.py +++ b/readthedocs_build/config/config.py @@ -132,6 +132,13 @@ def get_valid_formats(self): 'epub', ) + def get_valid_python_versions(self): + try: + return self.env_config['python']['supported_versions'] + except (KeyError, TypeError): + pass + return self.PYTHON_SUPPORTED_VERSIONS + def validate(self): """ Validate and process config into ``config`` attribute that contains the @@ -221,11 +228,10 @@ def validate_build(self): str(_build['image']), self.DOCKER_SUPPORTED_VERSIONS, ) + build['supported_python_versions'] = \ + DOCKER_BUILD_IMAGES[build['image']]['python']['supported_versions'] self['build'] = build - # Set the valid python versions for this container - img = build['image'] - self.PYTHON_SUPPORTED_VERSIONS = DOCKER_BUILD_IMAGES[img]['python']['supported_versions'] def validate_python(self): python = { From 3ae06857e788a327b3c65a998108abf56691f193 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Tue, 5 Dec 2017 10:46:43 -0800 Subject: [PATCH 07/14] Add back missing tests --- readthedocs_build/config/test_config.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/readthedocs_build/config/test_config.py b/readthedocs_build/config/test_config.py index b83fe7a..e2437b6 100644 --- a/readthedocs_build/config/test_config.py +++ b/readthedocs_build/config/test_config.py @@ -281,6 +281,23 @@ def it_validates_wrong_type_right_value(): build.validate_python() assert build['python']['version'] == 3 + def it_validates_env_supported_versions(): + build = get_build_config( + {'python': {'version': 3.6}}, + env_config={'python': {'supported_versions': [3.5]}} + ) + with raises(InvalidConfig) as excinfo: + build.validate_python() + assert excinfo.value.key == 'python.version' + assert excinfo.value.code == INVALID_CHOICE + + build = get_build_config( + {'python': {'version': 3.6}}, + env_config={'python': {'supported_versions': [3.5, 3.6]}} + ) + build.validate_python() + assert build['python']['version'] == 3.6 + def describe_validate_formats(): From 23cf764902ffe4ac0571972bff80cfc5e9c3a52d Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Tue, 5 Dec 2017 11:10:49 -0800 Subject: [PATCH 08/14] Clean up logic --- readthedocs_build/config/config.py | 33 ++++++++++++++++++------- readthedocs_build/config/test_config.py | 4 +-- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/readthedocs_build/config/config.py b/readthedocs_build/config/config.py index 2475dc3..8934758 100644 --- a/readthedocs_build/config/config.py +++ b/readthedocs_build/config/config.py @@ -26,14 +26,15 @@ TYPE_REQUIRED = 'type-required' PYTHON_INVALID = 'python-invalid' -DOCKER_BUILD_IMAGES = { - '1.0': { +DOCKER_IMAGE = 'readthedocs/build:2.0' +DOCKER_IMAGE_SETTINGS = { + 'readthedocs/build:1.0': { 'python': {'supported_versions': [2, 2.7, 3, 3.4]}, }, - '2.0': { + 'readthedocs/build:2.0': { 'python': {'supported_versions': [2, 2.7, 3, 3.5]}, }, - 'latest': { + 'readthedocs/build:latest': { 'python': {'supported_versions': [2, 2.7, 3, 3.3, 3.4, 3.5, 3.6]}, }, } @@ -219,7 +220,14 @@ def validate_base(self): def validate_build(self): # Defaults - build = {'image': '2.0'} + if 'build' in self.env_config: + build = self.env_config['build'] + else: + build = {'image': DOCKER_IMAGE} + + default_image = build['image'] + + # User specified if 'build' in self.raw_config: _build = self.raw_config['build'] if 'image' in _build: @@ -228,11 +236,18 @@ def validate_build(self): str(_build['image']), self.DOCKER_SUPPORTED_VERSIONS, ) - build['supported_python_versions'] = \ - DOCKER_BUILD_IMAGES[build['image']]['python']['supported_versions'] + if ':' not in build['image']: + # Prepend proper image name to user's image name + build['image'] = '{}:{}'.format( + default_image.split(':')[0], + build['image'] + ) + if build['image'] in DOCKER_IMAGE_SETTINGS: + self.env_config.update( + DOCKER_IMAGE_SETTINGS[build['image']] + ) self['build'] = build - def validate_python(self): python = { 'use_system_site_packages': False, @@ -308,7 +323,7 @@ def validate_python(self): pass python['version'] = validate_choice( version, - self.PYTHON_SUPPORTED_VERSIONS + self.get_valid_python_versions(), ) self['python'] = python diff --git a/readthedocs_build/config/test_config.py b/readthedocs_build/config/test_config.py index e2437b6..ca41a37 100644 --- a/readthedocs_build/config/test_config.py +++ b/readthedocs_build/config/test_config.py @@ -464,7 +464,7 @@ def it_works(tmpdir): source_file=str(tmpdir.join('readthedocs.yml')), source_position=0) build.validate_build() - assert build['build']['image'] == 'latest' + assert build['build']['image'] == 'readthedocs/build:latest' def default(tmpdir): apply_fs(tmpdir, minimal_config) @@ -474,7 +474,7 @@ def default(tmpdir): source_file=str(tmpdir.join('readthedocs.yml')), source_position=0) build.validate_build() - assert build['build']['image'] == '2.0' + assert build['build']['image'] == 'readthedocs/build:2.0' def test_build_validate_calls_all_subvalidators(tmpdir): From 91d49efa0a93b5c5f86955f3f9da36c170ca9eb8 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Tue, 5 Dec 2017 11:12:08 -0800 Subject: [PATCH 09/14] More small bits --- readthedocs_build/config/config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/readthedocs_build/config/config.py b/readthedocs_build/config/config.py index 8934758..73729dd 100644 --- a/readthedocs_build/config/config.py +++ b/readthedocs_build/config/config.py @@ -243,6 +243,7 @@ def validate_build(self): build['image'] ) if build['image'] in DOCKER_IMAGE_SETTINGS: + # Update docker settings from image name self.env_config.update( DOCKER_IMAGE_SETTINGS[build['image']] ) From de3e359b195abcbad4a77bed01dbdb3485947c15 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Tue, 5 Dec 2017 11:13:02 -0800 Subject: [PATCH 10/14] Cleanup linting --- readthedocs_build/config/config.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/readthedocs_build/config/config.py b/readthedocs_build/config/config.py index 73729dd..4b08790 100644 --- a/readthedocs_build/config/config.py +++ b/readthedocs_build/config/config.py @@ -125,6 +125,13 @@ def get_valid_types(self): 'sphinx', ) + def get_valid_python_versions(self): + try: + return self.env_config['python']['supported_versions'] + except (KeyError, TypeError): + pass + return self.PYTHON_SUPPORTED_VERSIONS + def get_valid_formats(self): return ( 'none', @@ -133,13 +140,6 @@ def get_valid_formats(self): 'epub', ) - def get_valid_python_versions(self): - try: - return self.env_config['python']['supported_versions'] - except (KeyError, TypeError): - pass - return self.PYTHON_SUPPORTED_VERSIONS - def validate(self): """ Validate and process config into ``config`` attribute that contains the From b597d3ba3accfe87bfbc278901961e49483b2739 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Tue, 5 Dec 2017 11:18:02 -0800 Subject: [PATCH 11/14] More docstrings --- readthedocs_build/config/config.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/readthedocs_build/config/config.py b/readthedocs_build/config/config.py index 4b08790..566f055 100644 --- a/readthedocs_build/config/config.py +++ b/readthedocs_build/config/config.py @@ -26,7 +26,9 @@ TYPE_REQUIRED = 'type-required' PYTHON_INVALID = 'python-invalid' -DOCKER_IMAGE = 'readthedocs/build:2.0' +DOCKER_DEFAULT_IMAGE = 'readthedocs/build' +DOCKER_DEFAULT_VERSION = '2.0' +DOCKER_IMAGE = '{}:{}'.format(DOCKER_DEFAULT_IMAGE, DOCKER_DEFAULT_VERSION) DOCKER_IMAGE_SETTINGS = { 'readthedocs/build:1.0': { 'python': {'supported_versions': [2, 2.7, 3, 3.4]}, @@ -219,14 +221,24 @@ def validate_base(self): self['base'] = base def validate_build(self): + """ + Validate the build config settings. + + This is a bit complex, + so here is the logic: + + * We take the default image & version if it's specific in the environment + * Then update the _version_ from the users config + * Then append the default _image_, since users can't change this + * Then update the env_config with the settings for that specific image + - This is currently used for a build image -> python version mapping + """ # Defaults if 'build' in self.env_config: build = self.env_config['build'] else: build = {'image': DOCKER_IMAGE} - default_image = build['image'] - # User specified if 'build' in self.raw_config: _build = self.raw_config['build'] @@ -239,7 +251,7 @@ def validate_build(self): if ':' not in build['image']: # Prepend proper image name to user's image name build['image'] = '{}:{}'.format( - default_image.split(':')[0], + DOCKER_DEFAULT_IMAGE, build['image'] ) if build['image'] in DOCKER_IMAGE_SETTINGS: From 73a184a8f28cc8fe156728916ddf30fa6cf8eada Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Tue, 5 Dec 2017 11:20:53 -0800 Subject: [PATCH 12/14] A bit more clarification --- readthedocs_build/config/config.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/readthedocs_build/config/config.py b/readthedocs_build/config/config.py index 566f055..fb99a95 100644 --- a/readthedocs_build/config/config.py +++ b/readthedocs_build/config/config.py @@ -28,6 +28,8 @@ DOCKER_DEFAULT_IMAGE = 'readthedocs/build' DOCKER_DEFAULT_VERSION = '2.0' +# These map to coordisponding settings in the .org, +# so they haven't been renamed. DOCKER_IMAGE = '{}:{}'.format(DOCKER_DEFAULT_IMAGE, DOCKER_DEFAULT_VERSION) DOCKER_IMAGE_SETTINGS = { 'readthedocs/build:1.0': { @@ -232,6 +234,9 @@ def validate_build(self): * Then append the default _image_, since users can't change this * Then update the env_config with the settings for that specific image - This is currently used for a build image -> python version mapping + + This means we can use custom docker _images_, + but can't change the supported _versions_ that users have defined. """ # Defaults if 'build' in self.env_config: From 79f78d23d367f7176c7f1509c71863b319dbb6df Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Tue, 5 Dec 2017 11:50:22 -0800 Subject: [PATCH 13/14] Fix logic --- readthedocs_build/config/config.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/readthedocs_build/config/config.py b/readthedocs_build/config/config.py index fb99a95..6ae7173 100644 --- a/readthedocs_build/config/config.py +++ b/readthedocs_build/config/config.py @@ -259,11 +259,11 @@ def validate_build(self): DOCKER_DEFAULT_IMAGE, build['image'] ) - if build['image'] in DOCKER_IMAGE_SETTINGS: - # Update docker settings from image name - self.env_config.update( - DOCKER_IMAGE_SETTINGS[build['image']] - ) + if build['image'] in DOCKER_IMAGE_SETTINGS: + # Update docker settings from image name + self.env_config.update( + DOCKER_IMAGE_SETTINGS[build['image']] + ) self['build'] = build def validate_python(self): From 8e8164eb72c4b2c95f5a50e895abd6fcd272c8a5 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Fri, 8 Dec 2017 14:21:24 -0800 Subject: [PATCH 14/14] Support passing full setting through --- readthedocs_build/config/config.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/readthedocs_build/config/config.py b/readthedocs_build/config/config.py index 6ae7173..d1d16d6 100644 --- a/readthedocs_build/config/config.py +++ b/readthedocs_build/config/config.py @@ -259,11 +259,17 @@ def validate_build(self): DOCKER_DEFAULT_IMAGE, build['image'] ) + # Update docker default settings from image name if build['image'] in DOCKER_IMAGE_SETTINGS: - # Update docker settings from image name self.env_config.update( DOCKER_IMAGE_SETTINGS[build['image']] ) + # Update docker settings from user config + if 'DOCKER_IMAGE_SETTINGS' in self.env_config and \ + build['image'] in self.env_config['DOCKER_IMAGE_SETTINGS']: + self.env_config.update( + self.env_config['DOCKER_IMAGE_SETTINGS'][build['image']] + ) self['build'] = build def validate_python(self):