mirror of https://github.com/docker/compose.git
Use true_name for remove operation
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
c1657dc46a
commit
3b2ce82fa1
|
@ -95,14 +95,11 @@ class Network(object):
|
|||
|
||||
def remove(self):
|
||||
if self.external:
|
||||
log.info("Network %s is external, skipping", self.full_name)
|
||||
log.info("Network %s is external, skipping", self.true_name)
|
||||
return
|
||||
|
||||
log.info("Removing network {}".format(self.true_name))
|
||||
try:
|
||||
self.client.remove_network(self.full_name)
|
||||
except NotFound:
|
||||
self.client.remove_network(self.legacy_full_name)
|
||||
self.client.remove_network(self.true_name)
|
||||
|
||||
def inspect(self, legacy=False):
|
||||
if legacy:
|
||||
|
|
|
@ -38,13 +38,10 @@ class Volume(object):
|
|||
|
||||
def remove(self):
|
||||
if self.external:
|
||||
log.info("Volume %s is external, skipping", self.full_name)
|
||||
log.info("Volume %s is external, skipping", self.true_name)
|
||||
return
|
||||
log.info("Removing volume %s", self.full_name)
|
||||
try:
|
||||
return self.client.remove_volume(self.full_name)
|
||||
except NotFound:
|
||||
self.client.remove_volume(self.legacy_full_name)
|
||||
log.info("Removing volume %s", self.true_name)
|
||||
return self.client.remove_volume(self.true_name)
|
||||
|
||||
def inspect(self, legacy=None):
|
||||
if legacy:
|
||||
|
|
|
@ -78,6 +78,7 @@ class NetworkTest(unittest.TestCase):
|
|||
{'Driver': 'overlay', 'Options': remote_options}, net
|
||||
)
|
||||
|
||||
@mock.patch('compose.network.Network.true_name', lambda n: n.full_name)
|
||||
def test_check_remote_network_config_driver_mismatch(self):
|
||||
net = Network(None, 'compose_test', 'net1', 'overlay')
|
||||
with pytest.raises(NetworkConfigChangedError) as e:
|
||||
|
@ -87,6 +88,7 @@ class NetworkTest(unittest.TestCase):
|
|||
|
||||
assert 'driver has changed' in str(e.value)
|
||||
|
||||
@mock.patch('compose.network.Network.true_name', lambda n: n.full_name)
|
||||
def test_check_remote_network_config_options_mismatch(self):
|
||||
net = Network(None, 'compose_test', 'net1', 'overlay')
|
||||
with pytest.raises(NetworkConfigChangedError) as e:
|
||||
|
@ -140,6 +142,7 @@ class NetworkTest(unittest.TestCase):
|
|||
net
|
||||
)
|
||||
|
||||
@mock.patch('compose.network.Network.true_name', lambda n: n.full_name)
|
||||
def test_check_remote_network_labels_mismatch(self):
|
||||
net = Network(None, 'compose_test', 'net1', 'overlay', labels={
|
||||
'com.project.touhou.character': 'sakuya.izayoi'
|
||||
|
|
|
@ -60,6 +60,7 @@ class ProjectTest(unittest.TestCase):
|
|||
assert project.get_service('db').options['image'] == 'busybox:latest'
|
||||
assert not project.networks.use_networking
|
||||
|
||||
@mock.patch('compose.network.Network.true_name', lambda n: n.full_name)
|
||||
def test_from_config_v2(self):
|
||||
config = Config(
|
||||
version=V2_0,
|
||||
|
@ -217,6 +218,7 @@ class ProjectTest(unittest.TestCase):
|
|||
)
|
||||
assert project.get_service('test')._get_volumes_from() == [container_name + ":rw"]
|
||||
|
||||
@mock.patch('compose.network.Network.true_name', lambda n: n.full_name)
|
||||
def test_use_volumes_from_service_container(self):
|
||||
container_ids = ['aabbccddee', '12345']
|
||||
|
||||
|
|
Loading…
Reference in New Issue