1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 23:09:41 +02:00

feat(custom-templates): filter templates by edge [EE-6565] (#10979)

This commit is contained in:
Chaim Lev-Ari 2024-01-28 15:54:34 +02:00 committed by GitHub
parent 441a8bbbbf
commit 2826a4ce39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 229 additions and 21 deletions

View file

@ -8,3 +8,16 @@ func Map[T, U any](s []T, f func(T) U) []U {
}
return result
}
// Filter returns a new slice containing only the elements of the slice for which the given predicate returns true
func Filter[T any](s []T, predicate func(T) bool) []T {
n := 0
for _, v := range s {
if predicate(v) {
s[n] = v
n++
}
}
return s[:n]
}