mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +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 != "" {
|
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) {
|
if err == nil && !strings.EqualFold(arg.TemplateName, template.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -1617,10 +1617,14 @@ func (q *fakeQuerier) ParameterValues(_ context.Context, arg database.ParameterV
|
|||||||
return parameterValues, nil
|
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()
|
q.mutex.RLock()
|
||||||
defer q.mutex.RUnlock()
|
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 {
|
for _, template := range q.templates {
|
||||||
if template.ID == id {
|
if template.ID == id {
|
||||||
return template, nil
|
return template, nil
|
||||||
|
Reference in New Issue
Block a user