Merge branch 'master' into 1.27.x

This commit is contained in:
aiordache 2020-09-10 15:08:45 +02:00
commit 4d8d0769a4
7 changed files with 37 additions and 32 deletions

View File

@ -36,6 +36,8 @@ Change log
### Miscellaneous ### Miscellaneous
- Drop support for Python 2.7
- Bump `docker-py` to 4.3.1 - Bump `docker-py` to 4.3.1
- Bump `tox` to 3.19.0 - Bump `tox` to 3.19.0
@ -44,6 +46,13 @@ Change log
- Add script for docs syncronization - Add script for docs syncronization
1.26.2 (2020-07-02)
-------------------
### Bugs
- Enforce `docker-py` 4.2.2 as minimum version when installing with pip
1.26.1 (2020-06-30) 1.26.1 (2020-06-30)
------------------- -------------------

View File

@ -1304,6 +1304,7 @@ def run_one_off_container(container_options, project, service, options, toplevel
native_builder = toplevel_environment.get_boolean('COMPOSE_DOCKER_CLI_BUILD') native_builder = toplevel_environment.get_boolean('COMPOSE_DOCKER_CLI_BUILD')
detach = options.get('--detach') detach = options.get('--detach')
use_network_aliases = options.get('--use-aliases') use_network_aliases = options.get('--use-aliases')
service.scale_num = 1
containers = project.up( containers = project.up(
service_names=[service.name], service_names=[service.name],
start_deps=not options['--no-deps'], start_deps=not options['--no-deps'],

View File

@ -224,8 +224,6 @@ class ConfigFile(namedtuple('_ConfigFile', 'filename config')):
if version.startswith("1"): if version.startswith("1"):
version = V1 version = V1
else:
version = VERSION
if version == V1: if version == V1:
raise ConfigurationError( raise ConfigurationError(
@ -441,6 +439,8 @@ def load_mapping(config_files, get_func, entity_type, working_dir=None):
def validate_external(entity_type, name, config, version): def validate_external(entity_type, name, config, version):
for k in config.keys(): for k in config.keys():
if entity_type == 'Network' and k == 'driver':
continue
if k not in ['external', 'name']: if k not in ['external', 'name']:
raise ConfigurationError( raise ConfigurationError(
"{} {} declared as external but specifies additional attributes " "{} {} declared as external but specifies additional attributes "

View File

@ -24,7 +24,7 @@ SECRETS_PATH = '/run/secrets'
WINDOWS_LONGPATH_PREFIX = '\\\\?\\' WINDOWS_LONGPATH_PREFIX = '\\\\?\\'
COMPOSEFILE_V1 = ComposeVersion('1') COMPOSEFILE_V1 = ComposeVersion('1')
COMPOSE_SPEC = ComposeVersion('3') COMPOSE_SPEC = ComposeVersion('3.9')
# minimum DOCKER ENGINE API version needed to support # minimum DOCKER ENGINE API version needed to support
# features for each compose schema version # features for each compose schema version

View File

@ -311,12 +311,12 @@ class Project:
return 1 if scale is None else scale return 1 if scale is None else scale
replicas = deploy_dict.get('replicas', None) replicas = deploy_dict.get('replicas', None)
if scale and replicas: if scale is not None and replicas is not None:
raise ConfigurationError( raise ConfigurationError(
"Both service.scale and service.deploy.replicas are set." "Both service.scale and service.deploy.replicas are set."
" Only one of them must be set." " Only one of them must be set."
) )
if replicas: if replicas is not None:
scale = replicas scale = replicas
if scale is None: if scale is None:
return 1 return 1

View File

@ -284,7 +284,7 @@ services:
output = yaml.safe_load(result.stdout) output = yaml.safe_load(result.stdout)
expected = { expected = {
'version': str(VERSION), 'version': '2',
'volumes': {'data': {'driver': 'local'}}, 'volumes': {'data': {'driver': 'local'}},
'networks': {'front': {}}, 'networks': {'front': {}},
'services': { 'services': {
@ -308,7 +308,7 @@ services:
self.base_dir = 'tests/fixtures/restart' self.base_dir = 'tests/fixtures/restart'
result = self.dispatch(['config']) result = self.dispatch(['config'])
assert yaml.safe_load(result.stdout) == { assert yaml.safe_load(result.stdout) == {
'version': str(VERSION), 'version': '2',
'services': { 'services': {
'never': { 'never': {
'image': 'busybox', 'image': 'busybox',
@ -354,12 +354,12 @@ services:
result = self.dispatch(['config']) result = self.dispatch(['config'])
json_result = yaml.safe_load(result.stdout) json_result = yaml.safe_load(result.stdout)
assert json_result == { assert json_result == {
'version': str(VERSION), 'version': '2.4',
'services': { 'services': {
'web': { 'web': {
'command': 'true', 'command': 'true',
'image': 'alpine:latest', 'image': 'alpine:latest',
'ports': [{'target': 5643}, {'target': 9999}] 'ports': ['5643/tcp', '9999/tcp']
} }
} }
} }
@ -369,12 +369,12 @@ services:
result = self.dispatch(['--env-file', '.env2', 'config']) result = self.dispatch(['--env-file', '.env2', 'config'])
json_result = yaml.safe_load(result.stdout) json_result = yaml.safe_load(result.stdout)
assert json_result == { assert json_result == {
'version': str(VERSION), 'version': '2.4',
'services': { 'services': {
'web': { 'web': {
'command': 'false', 'command': 'false',
'image': 'alpine:latest', 'image': 'alpine:latest',
'ports': [{'target': 5644}, {'target': 9998}] 'ports': ['5644/tcp', '9998/tcp']
} }
} }
} }
@ -384,12 +384,12 @@ services:
result = self.dispatch(['--project-directory', 'alt/', 'config']) result = self.dispatch(['--project-directory', 'alt/', 'config'])
json_result = yaml.safe_load(result.stdout) json_result = yaml.safe_load(result.stdout)
assert json_result == { assert json_result == {
'version': str(VERSION), 'version': '2.4',
'services': { 'services': {
'web': { 'web': {
'command': 'echo uwu', 'command': 'echo uwu',
'image': 'alpine:3.10.1', 'image': 'alpine:3.10.1',
'ports': [{'target': 3341}, {'target': 4449}] 'ports': ['3341/tcp', '4449/tcp']
} }
} }
} }
@ -501,7 +501,7 @@ services:
self.base_dir = 'tests/fixtures/v3-full' self.base_dir = 'tests/fixtures/v3-full'
result = self.dispatch(['config']) result = self.dispatch(['config'])
assert yaml.safe_load(result.stdout) == { assert yaml.safe_load(result.stdout) == {
'version': str(VERSION), 'version': '3.5',
'volumes': { 'volumes': {
'foobar': { 'foobar': {
'labels': { 'labels': {

View File

@ -160,25 +160,20 @@ class ConfigTest(unittest.TestCase):
} }
def test_valid_versions(self): def test_valid_versions(self):
for version in ['2', '2.0']: cfg = config.load(
build_config_details({
'services': {
'foo': {'image': 'busybox'},
'bar': {'image': 'busybox', 'environment': ['FOO=1']},
}
})
)
assert cfg.version == VERSION
for version in ['2', '2.0', '2.1', '2.2', '2.3',
'3', '3.0', '3.1', '3.2', '3.3', '3.4', '3.5', '3.6', '3.7', '3.8']:
cfg = config.load(build_config_details({'version': version})) cfg = config.load(build_config_details({'version': version}))
assert cfg.version == VERSION assert cfg.version == version
cfg = config.load(build_config_details({'version': '2.1'}))
assert cfg.version == VERSION
cfg = config.load(build_config_details({'version': '2.2'}))
assert cfg.version == VERSION
cfg = config.load(build_config_details({'version': '2.3'}))
assert cfg.version == VERSION
for version in ['3', '3.0']:
cfg = config.load(build_config_details({'version': version}))
assert cfg.version == VERSION
cfg = config.load(build_config_details({'version': '3.1'}))
assert cfg.version == VERSION
def test_v1_file_version(self): def test_v1_file_version(self):
cfg = config.load(build_config_details({'web': {'image': 'busybox'}})) cfg = config.load(build_config_details({'web': {'image': 'busybox'}}))