Decompose GetTemplatePrebuildState into separate queries, reimplement logic in Go

This is in service of testability

Signed-off-by: Danny Kopping <danny@coder.com>
This commit is contained in:
Danny Kopping
2025-02-20 14:57:01 +00:00
parent 64d476545b
commit 4d97580666
10 changed files with 485 additions and 384 deletions

View File

@ -77,6 +77,17 @@ func Find[T any](haystack []T, cond func(T) bool) (T, bool) {
return empty, false
}
// Filter returns all elements that satisfy the condition.
func Filter[T any](haystack []T, cond func(T) bool) []T {
out := make([]T, 0, len(haystack))
for _, hay := range haystack {
if cond(hay) {
out = append(out, hay)
}
}
return out
}
// Overlap returns if the 2 sets have any overlap (element(s) in common)
func Overlap[T comparable](a []T, b []T) bool {
return OverlapCompare(a, b, func(a, b T) bool {