mirror of
https://github.com/docker/compose.git
synced 2025-07-23 05:34:36 +02:00
fix flake8 complexity
Signed-off-by: aiordache <anca.iordache@docker.com>
This commit is contained in:
parent
8c81a9da7a
commit
c960b028b9
@ -433,24 +433,29 @@ def load_mapping(config_files, get_func, entity_type, working_dir=None):
|
|||||||
config['driver_opts'] = build_string_dict(
|
config['driver_opts'] = build_string_dict(
|
||||||
config['driver_opts']
|
config['driver_opts']
|
||||||
)
|
)
|
||||||
if entity_type != 'Volume':
|
device = format_device_option(entity_type, config)
|
||||||
continue
|
if device:
|
||||||
# default driver is 'local'
|
config['driver_opts']['device'] = device
|
||||||
driver = config.get('driver', 'local')
|
|
||||||
if driver != 'local':
|
|
||||||
continue
|
|
||||||
o = config['driver_opts'].get('o')
|
|
||||||
device = config['driver_opts'].get('device')
|
|
||||||
if o and o == 'bind' and device:
|
|
||||||
fullpath = os.path.abspath(os.path.expanduser(device))
|
|
||||||
if not os.path.exists(fullpath):
|
|
||||||
raise ConfigurationError(
|
|
||||||
"Device path {} does not exist.".format(fullpath))
|
|
||||||
config['driver_opts']['device'] = fullpath
|
|
||||||
|
|
||||||
return mapping
|
return mapping
|
||||||
|
|
||||||
|
|
||||||
|
def format_device_option(entity_type, config):
|
||||||
|
if entity_type != 'Volume':
|
||||||
|
return
|
||||||
|
# default driver is 'local'
|
||||||
|
driver = config.get('driver', 'local')
|
||||||
|
if driver != 'local':
|
||||||
|
return
|
||||||
|
o = config['driver_opts'].get('o')
|
||||||
|
device = config['driver_opts'].get('device')
|
||||||
|
if o and o == 'bind' and device:
|
||||||
|
fullpath = os.path.abspath(os.path.expanduser(device))
|
||||||
|
if not os.path.exists(fullpath):
|
||||||
|
raise ConfigurationError(
|
||||||
|
"Device path {} does not exist.".format(fullpath))
|
||||||
|
return fullpath
|
||||||
|
|
||||||
|
|
||||||
def validate_external(entity_type, name, config, version):
|
def validate_external(entity_type, name, config, version):
|
||||||
for k in config.keys():
|
for k in config.keys():
|
||||||
if entity_type == 'Network' and k == 'driver':
|
if entity_type == 'Network' and k == 'driver':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user