docker_container: Change expected config source (#57969)
* Change expected config source * make it conditional * rename property * Add changelog fragment * make it string * Update changelogs/fragments/57969-docker_container-change-expected-config-source.yml Co-Authored-By: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
f3720c90e0
commit
8c1c2afd02
2 changed files with 14 additions and 6 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- "docker_container - switch to ``Config`` data source for images (API>=1.21)."
|
|
@ -2099,7 +2099,7 @@ class Container(DockerBaseClass):
|
||||||
self.log('_get_expected_binds')
|
self.log('_get_expected_binds')
|
||||||
image_vols = []
|
image_vols = []
|
||||||
if image:
|
if image:
|
||||||
image_vols = self._get_image_binds(image['ContainerConfig'].get('Volumes'))
|
image_vols = self._get_image_binds(image[self.parameters.client.image_inspect_source].get('Volumes'))
|
||||||
param_vols = []
|
param_vols = []
|
||||||
if self.parameters.volumes:
|
if self.parameters.volumes:
|
||||||
for vol in self.parameters.volumes:
|
for vol in self.parameters.volumes:
|
||||||
|
@ -2149,8 +2149,8 @@ class Container(DockerBaseClass):
|
||||||
def _get_expected_volumes(self, image):
|
def _get_expected_volumes(self, image):
|
||||||
self.log('_get_expected_volumes')
|
self.log('_get_expected_volumes')
|
||||||
expected_vols = dict()
|
expected_vols = dict()
|
||||||
if image and image['ContainerConfig'].get('Volumes'):
|
if image and image[self.parameters.client.image_inspect_source].get('Volumes'):
|
||||||
expected_vols.update(image['ContainerConfig'].get('Volumes'))
|
expected_vols.update(image[self.parameters.client.image_inspect_source].get('Volumes'))
|
||||||
|
|
||||||
if self.parameters.volumes:
|
if self.parameters.volumes:
|
||||||
for vol in self.parameters.volumes:
|
for vol in self.parameters.volumes:
|
||||||
|
@ -2180,8 +2180,8 @@ class Container(DockerBaseClass):
|
||||||
def _get_expected_env(self, image):
|
def _get_expected_env(self, image):
|
||||||
self.log('_get_expected_env')
|
self.log('_get_expected_env')
|
||||||
expected_env = dict()
|
expected_env = dict()
|
||||||
if image and image['ContainerConfig'].get('Env'):
|
if image and image[self.parameters.client.image_inspect_source].get('Env'):
|
||||||
for env_var in image['ContainerConfig']['Env']:
|
for env_var in image[self.parameters.client.image_inspect_source]['Env']:
|
||||||
parts = env_var.split('=', 1)
|
parts = env_var.split('=', 1)
|
||||||
expected_env[parts[0]] = parts[1]
|
expected_env[parts[0]] = parts[1]
|
||||||
if self.parameters.env:
|
if self.parameters.env:
|
||||||
|
@ -2195,7 +2195,8 @@ class Container(DockerBaseClass):
|
||||||
self.log('_get_expected_exposed')
|
self.log('_get_expected_exposed')
|
||||||
image_ports = []
|
image_ports = []
|
||||||
if image:
|
if image:
|
||||||
image_ports = [self._normalize_port(p) for p in (image['ContainerConfig'].get('ExposedPorts') or {}).keys()]
|
image_exposed_ports = image[self.parameters.client.image_inspect_source].get('ExposedPorts') or {}
|
||||||
|
image_ports = [self._normalize_port(p) for p in image_exposed_ports.keys()]
|
||||||
param_ports = []
|
param_ports = []
|
||||||
if self.parameters.ports:
|
if self.parameters.ports:
|
||||||
param_ports = [str(p[0]) + '/' + p[1] for p in self.parameters.ports]
|
param_ports = [str(p[0]) + '/' + p[1] for p in self.parameters.ports]
|
||||||
|
@ -2873,6 +2874,11 @@ class AnsibleDockerClientContainer(AnsibleDockerClient):
|
||||||
option_minimal_versions_ignore_params=self.__NON_CONTAINER_PROPERTY_OPTIONS,
|
option_minimal_versions_ignore_params=self.__NON_CONTAINER_PROPERTY_OPTIONS,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.image_inspect_source = 'Config'
|
||||||
|
if self.docker_api_version < LooseVersion('1.21'):
|
||||||
|
self.image_inspect_source = 'ContainerConfig'
|
||||||
|
|
||||||
self._get_additional_minimal_versions()
|
self._get_additional_minimal_versions()
|
||||||
self._parse_comparisons()
|
self._parse_comparisons()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue