feat: evaluate only the parameter/preset/tag closure, with an opt-out - #226
Open
Emyrk wants to merge 3 commits into
Open
feat: evaluate only the parameter/preset/tag closure, with an opt-out#226Emyrk wants to merge 3 commits into
Emyrk wants to merge 3 commits into
Conversation
Preview now passes OptionWithResourceClosure to the parser by default so root resources nothing in the parameter, preset, or tag closure references are skipped. Preview takes variadic options; OptionFullEvaluation restores evaluating every resource, so a caller can turn the optimization off without a new preview release if a template misbehaves. Test_Extract runs every vector in both modes against the same expectations. Test_OptionFullEvaluation observes the difference through Output.ModuleOutput, which is the one output the closure changes.
Emyrk
marked this pull request as ready for review
September 11, 2026 20:42
geokat
approved these changes
Sep 11, 2026
geokat
left a comment
Contributor
There was a problem hiding this comment.
lgtm, other than the possible race (see comment).
Comment on lines
+888
to
+893
| if tc.unknownTags == nil { | ||
| tc.unknownTags = []string{} | ||
| } | ||
| if tc.expTags == nil { | ||
| tc.expTags = map[string]string{} | ||
| } |
Contributor
There was a problem hiding this comment.
We might have a race here now that we have parallel subtests sharing tc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Evaluates only the
coder_parameter/coder_workspace_preset/coder_workspace_tagsclosure when rendering, with an opt-out. Supersedes #221 (thanks @PushTheLimit); the trivy side is coder/trivy#74.OptionWithResourceClosure, and passes it by default so root resources nothing in the closure references are skipped. On the motivating templateEvaluateAlldrops from ~2s to ~0.16s.Previewtakesopts ...Option.OptionFullEvaluation()evaluates every resource, so coderd can turn the optimization off behind a setting without a new preview release if a template misbehaves.Test_Extractruns every vector in both modes against the same expectations, pinning that parameters, presets, tags, and variables are identical either way.Test_OptionFullEvaluationobserves the difference throughOutput.ModuleOutput.Behavior notes:
Output.ModuleOutputmay contain unknown values for root outputs that read pruned resources. Nothing in coderd consumes it..tf.jsonfiles skip pruning entirely (trivy's JSON reference extraction is not reliable enough to prune on).Test coverage for the reference shapes the pruner must see through landed separately in #223 and #224.
Prepared with Coder Agents assistance.