Filter mounts based on include/exclude patterns
This commit is contained in:
parent
6d896757b7
commit
f76c91e549
|
@ -39,13 +39,31 @@ class Container:
|
|||
def is_oneoff(self):
|
||||
return self.labels['com.docker.compose.oneoff'] == 'True'
|
||||
|
||||
def filter_mounts(self):
|
||||
"""Get all mounts for this container matching filters"""
|
||||
for mount in self.mounts:
|
||||
if self.include:
|
||||
for pattern in self.include:
|
||||
if pattern in mount.source:
|
||||
yield mount
|
||||
continue
|
||||
elif self.exlude:
|
||||
for pattern in self.exlude:
|
||||
if pattern in mount.source:
|
||||
continue
|
||||
yield mount
|
||||
else:
|
||||
yield mount
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
'Id': self.id,
|
||||
'Names': self.names,
|
||||
'State': self.state,
|
||||
'Labels': self.labels,
|
||||
'Mounts': [mnt.data for mnt in self.mounts]
|
||||
'Mounts': [mnt.data for mnt in self.mounts],
|
||||
'include': self.include,
|
||||
'exclude': self.exlude,
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,10 +155,6 @@ class RunningContainers:
|
|||
|
||||
self.containers.append(container)
|
||||
|
||||
|
||||
def backup_volumes(self):
|
||||
return self.backup_container.mounts
|
||||
|
||||
def gen_volumes(self, volume_type):
|
||||
"""Generator yielding volumes of a specific type"""
|
||||
for cont in self.containers:
|
||||
|
|
Loading…
Reference in New Issue