(ctx context.Context, arg GetTemplatesWithFilterParams, prepared rbac.PreparedAuthorized)
| 62 | } |
| 63 | |
| 64 | func (q *sqlQuerier) GetAuthorizedTemplates(ctx context.Context, arg GetTemplatesWithFilterParams, prepared rbac.PreparedAuthorized) ([]Template, error) { |
| 65 | authorizedFilter, err := prepared.CompileToSQL(ctx, regosql.ConvertConfig{ |
| 66 | VariableConverter: regosql.TemplateConverter(), |
| 67 | }) |
| 68 | if err != nil { |
| 69 | return nil, xerrors.Errorf("compile authorized filter: %w", err) |
| 70 | } |
| 71 | |
| 72 | filtered, err := insertAuthorizedFilter(getTemplatesWithFilter, fmt.Sprintf(" AND %s", authorizedFilter)) |
| 73 | if err != nil { |
| 74 | return nil, xerrors.Errorf("insert authorized filter: %w", err) |
| 75 | } |
| 76 | |
| 77 | // The name comment is for metric tracking |
| 78 | query := fmt.Sprintf("-- name: GetAuthorizedTemplates :many\n%s", filtered) |
| 79 | rows, err := q.db.QueryContext(ctx, query, |
| 80 | arg.Deleted, |
| 81 | arg.OrganizationID, |
| 82 | arg.ExactName, |
| 83 | arg.ExactDisplayName, |
| 84 | arg.FuzzyName, |
| 85 | arg.FuzzyDisplayName, |
| 86 | pq.Array(arg.IDs), |
| 87 | arg.Deprecated, |
| 88 | arg.HasAITask, |
| 89 | arg.AuthorID, |
| 90 | arg.AuthorUsername, |
| 91 | arg.HasExternalAgent, |
| 92 | ) |
| 93 | if err != nil { |
| 94 | return nil, err |
| 95 | } |
| 96 | defer rows.Close() |
| 97 | var items []Template |
| 98 | for rows.Next() { |
| 99 | var i Template |
| 100 | if err := rows.Scan( |
| 101 | &i.ID, |
| 102 | &i.CreatedAt, |
| 103 | &i.UpdatedAt, |
| 104 | &i.OrganizationID, |
| 105 | &i.Deleted, |
| 106 | &i.Name, |
| 107 | &i.Provisioner, |
| 108 | &i.ActiveVersionID, |
| 109 | &i.Description, |
| 110 | &i.DefaultTTL, |
| 111 | &i.CreatedBy, |
| 112 | &i.Icon, |
| 113 | &i.UserACL, |
| 114 | &i.GroupACL, |
| 115 | &i.DisplayName, |
| 116 | &i.AllowUserCancelWorkspaceJobs, |
| 117 | &i.AllowUserAutostart, |
| 118 | &i.AllowUserAutostop, |
| 119 | &i.FailureTTL, |
| 120 | &i.TimeTilDormant, |
| 121 | &i.TimeTilDormantAutoDelete, |
nothing calls this directly
no test coverage detected