- Notifications
You must be signed in to change notification settings - Fork917
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
Conversation
fb3b8ec
tod32f3e4
Compare41eebab
to31aa2b2
CompareThere 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.
@@ -25,7 +25,7 @@ func userACLMatcher(m sqltypes.VariableMatcher) sqltypes.VariableMatcher { | |||
func TemplateConverter() *sqltypes.VariableConverter { | |||
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
to0adf1f2
Compare0adf1f2
to32cc427
Comparereturn false, xerrors.Errorf("get workspace build parameters: %w", err) | ||
} | ||
for _, param := range parameters { | ||
if param.Name == "AI Prompt" && param.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
SELECT 1 | ||
FROM workspace_build_parameters | ||
WHERE workspace_build_parameters.workspace_build_id = latest_build.id | ||
AND workspace_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.
@@ -25,7 +25,7 @@ func userACLMatcher(m sqltypes.VariableMatcher) sqltypes.VariableMatcher { | |||
func TemplateConverter() *sqltypes.VariableConverter { | |||
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.
related to#18158 |
This PR allows filtering templates and workspaces with the
has-ai-task
filter as described in theCoder Tasks RFC.