mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 14:10:12 +01:00
always exclude containers that have the com.centurylinklabs.watchtower.enable set to false.
Fixes #169
This commit is contained in:
parent
026a04b59b
commit
6c12aee975
2 changed files with 29 additions and 3 deletions
|
|
@ -37,10 +37,23 @@ func filterByNames(names []string, baseFilter Filter) Filter {
|
|||
// Filters out containers that don't have the 'enableLabel'
|
||||
func filterByEnableLabel(baseFilter Filter) Filter {
|
||||
return func(c FilterableContainer) bool {
|
||||
// If label filtering is enabled, containers should only be enabled
|
||||
// if the label is specifically set to true.
|
||||
// If label filtering is enabled, containers should only be considered
|
||||
// if the label is specifically set.
|
||||
_, ok := c.Enabled()
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
return baseFilter(c)
|
||||
}
|
||||
}
|
||||
|
||||
// Filters out containers that have a 'enableLabel' and is set to disable.
|
||||
func filterByDisabledLabel(baseFilter Filter) Filter {
|
||||
return func(c FilterableContainer) bool {
|
||||
enabledLabel, ok := c.Enabled()
|
||||
if !ok || !enabledLabel {
|
||||
if ok && !enabledLabel {
|
||||
// If the label has been set and it demands a disable
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
@ -57,5 +70,6 @@ func BuildFilter(names []string, enableLabel bool) Filter {
|
|||
// if the label is specifically set.
|
||||
filter = filterByEnableLabel(filter)
|
||||
}
|
||||
filter = filterByDisabledLabel(filter)
|
||||
return filter
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue