Skip to content

Commit 64172d3

Browse files
authored
fix: set preset parameters in the API rather than the frontend (#17403)
Follow-up from a [previous Pull Request](#16965) required some additional testing of Presets from the API perspective. In the process of adding the new tests, I updated the API to enforce preset parameter values based on the selected preset instead of trusting whichever frontend makes the request. This avoids errors scenarios in prebuilds where a prebuild might expect a certain preset but find a different set of actual parameter values.
1 parent d78215c commit 64172d3

File tree

4 files changed

+387
-46
lines changed

4 files changed

+387
-46
lines changed

coderd/util/slice/slice.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ func Contains[T comparable](haystack []T, needle T) bool {
6666
})
6767
}
6868

69+
func CountMatchingPairs[A, B any](a []A, b []B, match func(A, B) bool) int {
70+
count := 0
71+
for _, a := range a {
72+
for _, b := range b {
73+
if match(a, b) {
74+
count++
75+
break
76+
}
77+
}
78+
}
79+
return count
80+
}
81+
6982
// Find returns the first element that satisfies the condition.
7083
func Find[T any](haystack []T, cond func(T) bool) (T, bool) {
7184
for _, hay := range haystack {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy