(ctx context.Context, ownerID uuid.UUID, values map[string]string)
| 226 | } |
| 227 | |
| 228 | func (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 | |
| 263 | func (r *dynamicRenderer) getWorkspaceOwnerData(ctx context.Context, ownerID uuid.UUID) error { |
| 264 | if r.currentOwner != nil && r.currentOwner.ID == ownerID.String() { |
nothing calls this directly
no test coverage detected