mirror of https://github.com/docker/compose.git
Merge pull request #1705 from aanand/fix-labels-null
Handle case where /containers/json returns "Labels": null
This commit is contained in:
commit
7b9664be8e
|
@ -149,7 +149,7 @@ def _get_legacy_containers_iter(
|
|||
|
||||
for service in services:
|
||||
for container in containers:
|
||||
if LABEL_VERSION in container['Labels']:
|
||||
if LABEL_VERSION in (container.get('Labels') or {}):
|
||||
continue
|
||||
|
||||
name = get_container_name(container)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import unittest
|
||||
from mock import Mock
|
||||
|
||||
from docker.errors import APIError
|
||||
|
||||
|
@ -64,6 +65,22 @@ class UtilitiesTestCase(unittest.TestCase):
|
|||
legacy.is_valid_name("composetest_web_lol_1", one_off=True),
|
||||
)
|
||||
|
||||
def test_get_legacy_containers_no_labels(self):
|
||||
client = Mock()
|
||||
client.containers.return_value = [
|
||||
{
|
||||
"Id": "abc123",
|
||||
"Image": "def456",
|
||||
"Name": "composetest_web_1",
|
||||
"Labels": None,
|
||||
},
|
||||
]
|
||||
|
||||
containers = list(legacy.get_legacy_containers(
|
||||
client, "composetest", ["web"]))
|
||||
|
||||
self.assertEqual(len(containers), 1)
|
||||
|
||||
|
||||
class LegacyTestCase(DockerClientTestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue