-
Notifications
You must be signed in to change notification settings - Fork 974
feat(coderd): add tasks list and get endpoints #19468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f8660ff
to
bd14ddd
Compare
ff91ceb
to
66fbc02
Compare
|
||
// tasksFromWorkspaces converts a slice of API workspaces into tasks, fetching | ||
// prompts and mapping status/state. | ||
func (api *API) tasksFromWorkspaces(ctx context.Context, apiWorkspaces []codersdk.Workspace) ([]codersdk.Task, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we fine with this not validating that the passed in workspaces are tasks? I understand that where it is currently called from we only pass tasks in, I'm just curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably no harm to filter out workspaces that are not "tasks", wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be an error if passed to this function. Handling exists in both list and get endpoints currently, before calling this, but I can add a guard here as well or try to consolidate some more of the code into this method.
|
||
// tasksFromWorkspaces converts a slice of API workspaces into tasks, fetching | ||
// prompts and mapping status/state. | ||
func (api *API) tasksFromWorkspaces(ctx context.Context, apiWorkspaces []codersdk.Workspace) ([]codersdk.Task, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably no harm to filter out workspaces that are not "tasks", wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes coder/internal#899
Example API response:
NOTE: For now I've opted not to implement task "state" filter. Will require joining workspace apps to the workspaces query which is already complex enough. Regular workspace filters (status = running) will work, though.