MCPcopy Index your code
hub / github.com/coder/coder / Render

Method Render

coderd/dynamicparameters/render.go:228–261  ·  view source on GitHub ↗
(ctx context.Context, ownerID uuid.UUID, values map[string]string)

Source from the content-addressed store, hash-verified

226}
227
228func (r *dynamicRenderer) Render(ctx context.Context, ownerID uuid.UUID, values map[string]string) (*preview.Output, hcl.Diagnostics) {
229 // Always start with the cached error, if we have one.
230 ownerErr := r.ownerErrors[ownerID]
231 if ownerErr == nil {
232 ownerErr = r.getWorkspaceOwnerData(ctx, ownerID)
233 }
234
235 if ownerErr != nil || r.currentOwner == nil {
236 r.ownerErrors[ownerID] = ownerErr
237 return nil, hcl.Diagnostics{
238 {
239 Severity: hcl.DiagError,
240 Summary: "Failed to fetch workspace owner",
241 Detail: "Please check your permissions or the user may not exist.",
242 Extra: previewtypes.DiagnosticExtra{
243 Code: "owner_not_found",
244 },
245 },
246 }
247 }
248
249 input := preview.Input{
250 PlanJSON: r.data.terraformValues.CachedPlan,
251 ParameterValues: values,
252 Owner: *r.currentOwner,
253 TFVars: r.tfvarValues,
254 // Do not emit parser logs to coderd output logs.
255 // TODO: Returning this logs in the output would benefit the caller.
256 // Unsure how large the logs can be, so for now we just discard them.
257 Logger: slog.New(slog.DiscardHandler),
258 }
259
260 return preview.Preview(ctx, input, r.templateFS)
261}
262
263func (r *dynamicRenderer) getWorkspaceOwnerData(ctx context.Context, ownerID uuid.UUID) error {
264 if r.currentOwner != nil && r.currentOwner.ID == ownerID.String() {

Callers

nothing calls this directly

Calls 2

getWorkspaceOwnerDataMethod · 0.95
NewMethod · 0.65

Tested by

no test coverage detected