fix(community.docker.docker_volume): labels can be none (#702)

* fix(community.docker.docker_volume): labels can be none

catch case where volume labels can are done (default) eg:

$ docker volume inspect foo
[    
    {
        "CreatedAt": "2023-11-11T12:55:23+01:00",                                                                                                            
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/foo/_data",
        "Name": "foo",
        "Options": {},
        "Scope": "local"
    }
]

* Update plugins/modules/docker_volume.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* add(community.docker.docker_volume): changelog fragment

* Update changelogs/fragments/702-docker-volume-label-none.yaml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Alexander Jähnel
2023-11-12 11:19:56 +01:00
committed by GitHub
parent 9ba09432a7
commit 4c220c4d74
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -214,7 +214,7 @@ class DockerVolumeManager(object):
parameter=value,
active=self.existing_volume['Options'].get(key))
if self.parameters.labels:
existing_labels = self.existing_volume.get('Labels', {})
existing_labels = self.existing_volume.get('Labels') or {}
for label in self.parameters.labels:
if existing_labels.get(label) != self.parameters.labels.get(label):
differences.add('labels.%s' % label,