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

Skip to content

feat(coderd): add include_related parser in its own package - #28639

Merged
spikecurtis merged 2 commits into
mainfrom
spikecurtis/include-related-parser
Sep 11, 2026
Merged

feat(coderd): add include_related parser in its own package#28639
spikecurtis merged 2 commits into
mainfrom
spikecurtis/include-related-parser

Conversation

@spikecurtis

Copy link
Copy Markdown
Contributor

Part of the lite codersdk.Workspace work (GRU-82, RFC), following #28302 and #28367.

This adds a self-contained coderd/wsrelated package that models which workspace-related database objects to load and parses the include_related query parameter into that model. The related-data selection type and constructors that previously lived in coderd move here (now exported as wsrelated.Config, wsrelated.LatestBuild, etc., with wsrelated.All), and coderd uses the package.

wsrelated.Parse accepts a comma-separated list of dotted hierarchy paths, e.g. template,latest_build.resources.agents.*. Each path may end in a single trailing * wildcard that selects the node and all of its descendants; * on its own selects everything. Selecting a node selects its ancestors, which is a structural invariant of the pointer-tree type (a child cannot be expressed without its parent). Unknown paths, misplaced wildcards, and empty entries (e.g. a,,b) are errors; a single optional trailing comma is allowed. The parsing schema is built once in init rather than per call.

This is parser-only to keep the PR small; wiring Parse into the HTTP endpoints that produce codersdk.Workspace objects comes in a follow-up.


Generated by Coder Agents on behalf of @spikecurtis.

@spikecurtis
spikecurtis requested a review from cstyan August 26, 2026 13:51
@spikecurtis spikecurtis changed the title feat(coderd/wsrelated): add include_related parser in its own package feat(coderd): add include_related parser in its own package Aug 26, 2026
@spikecurtis
spikecurtis marked this pull request as ready for review August 26, 2026 14:17

@cstyan cstyan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one organizational related nit

Comment thread coderd/wsrelated/parse.go Outdated
Comment on lines +27 to +60
func (c *Config) ensureLatestBuild() *LatestBuild {
if c.LatestBuild == nil {
c.LatestBuild = &LatestBuild{}
}
return c.LatestBuild
}

func (c *LatestBuild) ensureJob() *Job {
if c.Job == nil {
c.Job = &Job{}
}
return c.Job
}

func (c *LatestBuild) ensureResources() *Resources {
if c.Resources == nil {
c.Resources = &Resources{}
}
return c.Resources
}

func (c *Resources) ensureAgents() *Agents {
if c.Agents == nil {
c.Agents = &Agents{}
}
return c.Agents
}

func (c *Agents) ensureApps() *Apps {
if c.Apps == nil {
c.Apps = &Apps{}
}
return c.Apps
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit but IMO functions for these structs should live in related.go where the structs themselves are defined

@spikecurtis
spikecurtis force-pushed the spikecurtis/include-related-parser branch from f09635b to 5a292bb Compare September 11, 2026 12:55
@spikecurtis
spikecurtis enabled auto-merge (squash) September 11, 2026 12:57
@spikecurtis
spikecurtis merged commit 508482d into main Sep 11, 2026
28 checks passed
@spikecurtis
spikecurtis deleted the spikecurtis/include-related-parser branch September 11, 2026 13:06
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants