mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
feat: implement dynamic parameter validation (#18482)
# What does this do?
This does parameter validation for dynamic parameters in `wsbuilder`. All input parameters are validated in `coder/coder` before being sent to terraform.
The heart of this PR is [`ResolveParameters`](b65001e89c/coderd/dynamicparameters/resolver.go (L30-L30)
).
# What else changes?
`wsbuilder` now needs to load the terraform files into memory to succeed. This does add a larger memory requirement to workspace builds.
# Future work
- Sort autostart handling workspaces by template version id. So workspaces with the same template version only load the terraform files once from the db, and store them in the cache.
This commit is contained in:
@ -49,7 +49,7 @@ type loader struct {
|
||||
// Prepare is the entrypoint for this package. It loads the necessary objects &
|
||||
// files from the database and returns a Renderer that can be used to render the
|
||||
// template version's parameters.
|
||||
func Prepare(ctx context.Context, db database.Store, cache *files.Cache, versionID uuid.UUID, options ...func(r *loader)) (Renderer, error) {
|
||||
func Prepare(ctx context.Context, db database.Store, cache files.FileAcquirer, versionID uuid.UUID, options ...func(r *loader)) (Renderer, error) {
|
||||
l := &loader{
|
||||
templateVersionID: versionID,
|
||||
}
|
||||
@ -137,7 +137,7 @@ func (r *loader) loadData(ctx context.Context, db database.Store) error {
|
||||
// Static parameter rendering is required to support older template versions that
|
||||
// do not have the database state to support dynamic parameters. A constant
|
||||
// warning will be displayed for these template versions.
|
||||
func (r *loader) Renderer(ctx context.Context, db database.Store, cache *files.Cache) (Renderer, error) {
|
||||
func (r *loader) Renderer(ctx context.Context, db database.Store, cache files.FileAcquirer) (Renderer, error) {
|
||||
err := r.loadData(ctx, db)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("load data: %w", err)
|
||||
|
Reference in New Issue
Block a user