mirror of https://github.com/docker/compose.git
Build labels option: array form produces unmarshal error (fixes #5183)
Signed-off-by: Guillermo Arribas <garribas@gmail.com>
This commit is contained in:
parent
08714ef796
commit
6de646d3b0
|
@ -23,6 +23,7 @@ from . import const
|
||||||
from . import progress_stream
|
from . import progress_stream
|
||||||
from .config import DOCKER_CONFIG_KEYS
|
from .config import DOCKER_CONFIG_KEYS
|
||||||
from .config import merge_environment
|
from .config import merge_environment
|
||||||
|
from .config.config import parse_labels
|
||||||
from .config.errors import DependencyError
|
from .config.errors import DependencyError
|
||||||
from .config.types import ServicePort
|
from .config.types import ServicePort
|
||||||
from .config.types import VolumeSpec
|
from .config.types import VolumeSpec
|
||||||
|
@ -916,7 +917,7 @@ class Service(object):
|
||||||
nocache=no_cache,
|
nocache=no_cache,
|
||||||
dockerfile=build_opts.get('dockerfile', None),
|
dockerfile=build_opts.get('dockerfile', None),
|
||||||
cache_from=build_opts.get('cache_from', None),
|
cache_from=build_opts.get('cache_from', None),
|
||||||
labels=build_opts.get('labels', None),
|
labels=parse_labels(build_opts.get('labels', None)),
|
||||||
buildargs=build_args,
|
buildargs=build_args,
|
||||||
network_mode=build_opts.get('network', None),
|
network_mode=build_opts.get('network', None),
|
||||||
target=build_opts.get('target', None),
|
target=build_opts.get('target', None),
|
||||||
|
|
|
@ -761,7 +761,7 @@ class ServiceTest(DockerClientTestCase):
|
||||||
assert service.image()
|
assert service.image()
|
||||||
assert "build_version=2" in service.image()['ContainerConfig']['Cmd']
|
assert "build_version=2" in service.image()['ContainerConfig']['Cmd']
|
||||||
|
|
||||||
def test_build_with_build_labels(self):
|
def test_build_with_build_labels_dict(self):
|
||||||
base_dir = tempfile.mkdtemp()
|
base_dir = tempfile.mkdtemp()
|
||||||
self.addCleanup(shutil.rmtree, base_dir)
|
self.addCleanup(shutil.rmtree, base_dir)
|
||||||
|
|
||||||
|
@ -778,6 +778,23 @@ class ServiceTest(DockerClientTestCase):
|
||||||
assert service.image()
|
assert service.image()
|
||||||
assert service.image()['Config']['Labels']['com.docker.compose.test'] == 'true'
|
assert service.image()['Config']['Labels']['com.docker.compose.test'] == 'true'
|
||||||
|
|
||||||
|
def test_build_with_build_labels_list(self):
|
||||||
|
base_dir = tempfile.mkdtemp()
|
||||||
|
self.addCleanup(shutil.rmtree, base_dir)
|
||||||
|
|
||||||
|
with open(os.path.join(base_dir, 'Dockerfile'), 'w') as f:
|
||||||
|
f.write('FROM busybox\n')
|
||||||
|
|
||||||
|
service = self.create_service('buildlabels', build={
|
||||||
|
'context': text_type(base_dir),
|
||||||
|
'labels': ['com.docker.compose.test=true']
|
||||||
|
})
|
||||||
|
service.build()
|
||||||
|
self.addCleanup(self.client.remove_image, service.image_name)
|
||||||
|
|
||||||
|
assert service.image()
|
||||||
|
assert service.image()['Config']['Labels']['com.docker.compose.test'] == 'true'
|
||||||
|
|
||||||
@no_cluster('Container networks not on Swarm')
|
@no_cluster('Container networks not on Swarm')
|
||||||
def test_build_with_network(self):
|
def test_build_with_network(self):
|
||||||
base_dir = tempfile.mkdtemp()
|
base_dir = tempfile.mkdtemp()
|
||||||
|
|
|
@ -473,7 +473,7 @@ class ServiceTest(unittest.TestCase):
|
||||||
nocache=False,
|
nocache=False,
|
||||||
rm=True,
|
rm=True,
|
||||||
buildargs={},
|
buildargs={},
|
||||||
labels=None,
|
labels={},
|
||||||
cache_from=None,
|
cache_from=None,
|
||||||
network_mode=None,
|
network_mode=None,
|
||||||
target=None,
|
target=None,
|
||||||
|
@ -514,7 +514,7 @@ class ServiceTest(unittest.TestCase):
|
||||||
nocache=False,
|
nocache=False,
|
||||||
rm=True,
|
rm=True,
|
||||||
buildargs={},
|
buildargs={},
|
||||||
labels=None,
|
labels={},
|
||||||
cache_from=None,
|
cache_from=None,
|
||||||
network_mode=None,
|
network_mode=None,
|
||||||
target=None,
|
target=None,
|
||||||
|
|
Loading…
Reference in New Issue