mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
fix: set preset parameters in the API rather than the frontend (#17403)
Follow-up from a [previous Pull Request](https://github.com/coder/coder/pull/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.
This commit is contained in:
@ -66,6 +66,19 @@ func Contains[T comparable](haystack []T, needle T) bool {
|
||||
})
|
||||
}
|
||||
|
||||
func CountMatchingPairs[A, B any](a []A, b []B, match func(A, B) bool) int {
|
||||
count := 0
|
||||
for _, a := range a {
|
||||
for _, b := range b {
|
||||
if match(a, b) {
|
||||
count++
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Find returns the first element that satisfies the condition.
|
||||
func Find[T any](haystack []T, cond func(T) bool) (T, bool) {
|
||||
for _, hay := range haystack {
|
||||
|
Reference in New Issue
Block a user