mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
chore: fetch templates by id without lock in dbfake (#6351)
See https://github.com/coder/coder/actions/runs/4276632002/jobs/7444857508
This commit is contained in:
@ -936,7 +936,7 @@ func (q *fakeQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg database.
|
||||
}
|
||||
|
||||
if arg.TemplateName != "" {
|
||||
template, err := q.GetTemplateByID(ctx, workspace.TemplateID)
|
||||
template, err := q.getTemplateByIDNoLock(ctx, workspace.TemplateID)
|
||||
if err == nil && !strings.EqualFold(arg.TemplateName, template.Name) {
|
||||
continue
|
||||
}
|
||||
@ -1617,10 +1617,14 @@ func (q *fakeQuerier) ParameterValues(_ context.Context, arg database.ParameterV
|
||||
return parameterValues, nil
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) GetTemplateByID(_ context.Context, id uuid.UUID) (database.Template, error) {
|
||||
func (q *fakeQuerier) GetTemplateByID(ctx context.Context, id uuid.UUID) (database.Template, error) {
|
||||
q.mutex.RLock()
|
||||
defer q.mutex.RUnlock()
|
||||
|
||||
return q.getTemplateByIDNoLock(ctx, id)
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) getTemplateByIDNoLock(_ context.Context, id uuid.UUID) (database.Template, error) {
|
||||
for _, template := range q.templates {
|
||||
if template.ID == id {
|
||||
return template, nil
|
||||
|
Reference in New Issue
Block a user