- Notifications
You must be signed in to change notification settings - Fork1.1k
feat: add has-ai-task filters to the /workspaces and /templates endpoints#18387
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
fb3b8ec tod32f3e4Compare41eebab to31aa2b2Compare
dannykopping left a comment
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.
LGTM, with a couple nits.
| matcher:=sqltypes.NewVariableConverter().RegisterMatcher( | ||
| resourceIDMatcher(), | ||
| organizationOwnerMatcher(), | ||
| sqltypes.StringVarMatcher("t.organization_id :: text", []string{"input","object","org_owner"}), |
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.
Is this the only case where we need to update theorganization_id alias?
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.
Bump
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.
Oh, sorry about that - yes, that's the only place. Only the SQL filter of theGetTemplates query is affected, andTemplateConverter is only used forGetTemplates.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
eaae6a8 to0adf1f2Compare0adf1f2 to32cc427Compare| returnfalse,xerrors.Errorf("get workspace build parameters: %w",err) | ||
| } | ||
| for_,param:=rangeparameters { | ||
| ifparam.Name=="AI Prompt"&¶m.Value!="" { |
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.
TODO: this should use the const I'm introducing in the provider:https://github.com/coder/terraform-provider-coder/blob/dk/coder-ai-task-res/provider/ai_task.go#L22
| SELECT1 | ||
| FROM workspace_build_parameters | ||
| WHEREworkspace_build_parameters.workspace_build_id=latest_build.id | ||
| ANDworkspace_build_parameters.name='AI Prompt' |
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.
Hmm we may want to accept this name as an arg, but could get tricky since this is used in a few places.
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.
If we want to enforce that this constant matches the constant in go code, I'd rather define a helper function:
CREATEFUNCTIONai_prompt_param_name() RETURNSTEXTAS $$BEGIN RETURN'AI Prompt';END;$$ LANGUAGE plpgsql IMMUTABLE;
Then use that function in the query, and add a test that checks if the result of that function matches the constant in go code.
| matcher:=sqltypes.NewVariableConverter().RegisterMatcher( | ||
| resourceIDMatcher(), | ||
| organizationOwnerMatcher(), | ||
| sqltypes.StringVarMatcher("t.organization_id :: text", []string{"input","object","org_owner"}), |
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.
Bump
591f5db intomainUh oh!
There was an error while loading.Please reload this page.
hugodutka commentedJun 19, 2025
related to#18158 |
This PR allows filtering templates and workspaces with the
has-ai-taskfilter as described in theCoder Tasks RFC.