chore: refactor dynamic parameters into dedicated package (#18420)

This PR extracts dynamic parameter rendering logic from
coderd/parameters.go into a new coderd/dynamicparameters package. Partly
for organization and maintainability, but primarily to be reused in
`wsbuilder` to be leveraged as validation.
This commit is contained in:
Steven Masley
2025-06-20 13:00:39 -05:00
committed by GitHub
parent 72f7d70bab
commit 9b5d49967c
10 changed files with 942 additions and 410 deletions

View File

@ -217,3 +217,16 @@ func CountConsecutive[T comparable](needle T, haystack ...T) int {
return max(maxLength, curLength)
}
// Convert converts a slice of type F to a slice of type T using the provided function f.
func Convert[F any, T any](a []F, f func(F) T) []T {
if a == nil {
return []T{}
}
tmp := make([]T, 0, len(a))
for _, v := range a {
tmp = append(tmp, f(v))
}
return tmp
}