mirror of https://github.com/docker/compose.git
Prevent KeyError when remote network labels are None.
Signed-off-by: Danil Kister <danil.kister@gmail.com>
This commit is contained in:
parent
525bc9ef7a
commit
a5fbf91b72
|
@ -226,7 +226,7 @@ def check_remote_network_config(remote, local):
|
||||||
raise NetworkConfigChangedError(local.true_name, 'enable_ipv6')
|
raise NetworkConfigChangedError(local.true_name, 'enable_ipv6')
|
||||||
|
|
||||||
local_labels = local.labels or {}
|
local_labels = local.labels or {}
|
||||||
remote_labels = remote.get('Labels', {})
|
remote_labels = remote.get('Labels') or {}
|
||||||
for k in set.union(set(remote_labels.keys()), set(local_labels.keys())):
|
for k in set.union(set(remote_labels.keys()), set(local_labels.keys())):
|
||||||
if k.startswith('com.docker.'): # We are only interested in user-specified labels
|
if k.startswith('com.docker.'): # We are only interested in user-specified labels
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -168,3 +168,8 @@ class NetworkTest(unittest.TestCase):
|
||||||
mock_log.warning.assert_called_once_with(mock.ANY)
|
mock_log.warning.assert_called_once_with(mock.ANY)
|
||||||
_, args, kwargs = mock_log.warning.mock_calls[0]
|
_, args, kwargs = mock_log.warning.mock_calls[0]
|
||||||
assert 'label "com.project.touhou.character" has changed' in args[0]
|
assert 'label "com.project.touhou.character" has changed' in args[0]
|
||||||
|
|
||||||
|
def test_remote_config_labels_none(self):
|
||||||
|
remote = {'Labels': None}
|
||||||
|
local = Network(None, 'test_project', 'test_network')
|
||||||
|
check_remote_network_config(remote, local)
|
||||||
|
|
Loading…
Reference in New Issue