mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 06:06:38 +01:00
feat: add support for "none" scope (#1800)
This commit is contained in:
parent
40b8c77100
commit
dd54055143
4 changed files with 92 additions and 19 deletions
|
|
@ -86,13 +86,14 @@ func FilterByDisabledLabel(baseFilter t.Filter) t.Filter {
|
|||
|
||||
// FilterByScope returns all containers that belongs to a specific scope
|
||||
func FilterByScope(scope string, baseFilter t.Filter) t.Filter {
|
||||
if scope == "" {
|
||||
return baseFilter
|
||||
}
|
||||
|
||||
return func(c t.FilterableContainer) bool {
|
||||
containerScope, ok := c.Scope()
|
||||
if ok && containerScope == scope {
|
||||
containerScope, containerHasScope := c.Scope()
|
||||
|
||||
if !containerHasScope || containerScope == "" {
|
||||
containerScope = "none"
|
||||
}
|
||||
|
||||
if containerScope == scope {
|
||||
return baseFilter(c)
|
||||
}
|
||||
|
||||
|
|
@ -152,7 +153,13 @@ func BuildFilter(names []string, disableNames []string, enableLabel bool, scope
|
|||
filter = FilterByEnableLabel(filter)
|
||||
sb.WriteString("using enable label, ")
|
||||
}
|
||||
if scope != "" {
|
||||
|
||||
if scope == "none" {
|
||||
// If a scope has explicitly defined as "none", containers should only be considered
|
||||
// if they do not have a scope defined, or if it's explicitly set to "none".
|
||||
filter = FilterByScope(scope, filter)
|
||||
sb.WriteString(`without a scope, "`)
|
||||
} else if scope != "" {
|
||||
// If a scope has been defined, containers should only be considered
|
||||
// if the scope is specifically set.
|
||||
filter = FilterByScope(scope, filter)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue