error on duplicate mount points

Signed-off-by: Collins Abitekaniza <abtcolns@gmail.com>
This commit is contained in:
Collins Abitekaniza 2018-12-08 13:48:05 +03:00
parent c139455fce
commit d980d170a6
2 changed files with 13 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import os
import string
import sys
from collections import namedtuple
from operator import itemgetter, attrgetter
import six
import yaml
@ -835,6 +836,17 @@ def finalize_service_volumes(service_dict, environment):
finalized_volumes.append(MountSpec.parse(v, normalize, win_host))
else:
finalized_volumes.append(VolumeSpec.parse(v, normalize, win_host))
duplicate_mounts = []
mounts = [v.as_volume_spec() if isinstance(v, MountSpec) else v for v in finalized_volumes]
for mount in mounts:
if list(map(attrgetter('internal'), mounts)).count(mount.internal) > 1:
duplicate_mounts.append(mount.repr())
if duplicate_mounts:
raise ConfigurationError("Duplicate mount points: volumes [%s]" % (
', '.join(duplicate_mounts)))
service_dict['volumes'] = finalized_volumes
return service_dict

View File

@ -9,6 +9,7 @@ import sys
from collections import namedtuple
from collections import OrderedDict
from operator import attrgetter
from operator import itemgetter
import enum
import six