Allow glob matches for roles and hosts

This lets you do things like:

```
kamal details -h '1.1.1.[1-9]'
kamal details -r 'w{eb,orkers}'
```
This commit is contained in:
Donal McBreen
2024-04-26 13:32:24 +01:00
parent d475e88dbe
commit f785451cc7
2 changed files with 8 additions and 3 deletions

View File

@@ -66,13 +66,12 @@ module Kamal::Utils
Array(filters).select do |filter|
matches += Array(items).select do |item|
# Only allow * for a wildcard
pattern = Regexp.escape(filter).gsub('\*', ".*")
# items are roles or hosts
(item.respond_to?(:name) ? item.name : item).match(/^#{pattern}$/)
File.fnmatch(filter, item.to_s, File::FNM_EXTGLOB)
end
end
matches
matches.uniq
end
def stable_sort!(elements, &block)