Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7a1622d

Browse files
committed
add comment, remove unused field
1 parent 21b24d2 commit 7a1622d

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

coderd/dynamicparameters/render.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package dynamicparameters
22

33
import (
44
"context"
5-
"encoding/json"
65
"io/fs"
6+
"log/slog"
77
"sync"
88

99
"github.com/google/uuid"
@@ -152,16 +152,10 @@ func (r *Loader) dynamicRenderer(ctx context.Context, db database.Store, cache *
152152
terraformFS = files.NewOverlayFS(templateFS, []files.Overlay{{Path: ".terraform/modules", FS: moduleFilesFS}})
153153
}
154154

155-
plan := json.RawMessage("{}")
156-
if len(r.terraformValues.CachedPlan) > 0 {
157-
plan = r.terraformValues.CachedPlan
158-
}
159-
160155
return &dynamicRenderer{
161156
data: r,
162157
templateFS: terraformFS,
163158
db: db,
164-
plan: plan,
165159
ownerErrors: make(map[uuid.UUID]error),
166160
close: func() {
167161
// Up to 2 files are cached, and must be released when rendering is complete.
@@ -179,7 +173,6 @@ type dynamicRenderer struct {
179173
db database.Store
180174
data *Loader
181175
templateFS fs.FS
182-
plan json.RawMessage
183176

184177
ownerErrors map[uuid.UUID]error
185178
currentOwner *previewtypes.WorkspaceOwner
@@ -213,6 +206,10 @@ func (r *dynamicRenderer) Render(ctx context.Context, ownerID uuid.UUID, values
213206
PlanJSON: r.data.terraformValues.CachedPlan,
214207
ParameterValues: values,
215208
Owner: *r.currentOwner,
209+
// Do not emit parser logs to coderd output logs.
210+
// TODO: Returning this logs in the output would benefit the caller.
211+
// Unsure how large the logs can be, so for now we just discard them.
212+
Logger: slog.New(slog.DiscardHandler),
216213
}
217214

218215
return preview.Preview(ctx, input, r.templateFS)

coderd/parameters.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ func (api *API) templateVersionDynamicParametersWebsocket(rw http.ResponseWriter
6868
})(rw, r)
6969
}
7070

71+
// The `listen` control flag determines whether to open a websocket connection to
72+
// handle the request or not. This same function is used to 'evaluate' a template
73+
// as a single invocation, or to 'listen' for a back and forth interaction with
74+
// the user to update the form as they type.
75+
//
7176
//nolint:revive // listen is a control flag
7277
func (api *API) templateVersionDynamicParameters(listen bool, initial codersdk.DynamicParametersRequest) func(rw http.ResponseWriter, r *http.Request) {
7378
return func(rw http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)