Use a if/else instead to avoid loading possibly invalid values for Memory

This commit is contained in:
Micheal Waltz 2015-07-23 12:17:26 -07:00 committed by Matt Clay
parent af5e402b87
commit 950701ba3e

View file

@ -1039,10 +1039,10 @@ class DockerManager(object):
except ValueError as e: except ValueError as e:
self.module.fail_json(msg=str(e)) self.module.fail_json(msg=str(e))
#For v1.19 API and above use HostConfig, otherwise use Config
if docker_api_version >= 1.19:
actual_mem = container['HostConfig']['Memory'] actual_mem = container['HostConfig']['Memory']
else:
#Use v1.18 API and earlier Memory element location
if docker_api_version <= 1.18:
actual_mem = container['Config']['Memory'] actual_mem = container['Config']['Memory']
if expected_mem and actual_mem != expected_mem: if expected_mem and actual_mem != expected_mem: