mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: persist prebuild definitions on template import (#16951)
This PR allows provisioners to recognise and report prebuild definitions to the coder control plane. It also allows the coder control plane to then persist these to its store. closes https://github.com/coder/internal/issues/507 --------- Signed-off-by: Danny Kopping <dannykopping@gmail.com> Co-authored-by: Danny Kopping <dannykopping@gmail.com> Co-authored-by: evgeniy-scherbina <evgeniy.shcherbina.es@gmail.com>
This commit is contained in:
co-authored by
Danny Kopping
evgeniy-scherbina
parent
074ec2887d
commit
0b2b643ce2
@@ -6389,6 +6389,43 @@ func (q *sqlQuerier) GetPresetByWorkspaceBuildID(ctx context.Context, workspaceB
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getPresetParametersByPresetID = `-- name: GetPresetParametersByPresetID :many
|
||||
SELECT
|
||||
tvpp.id, tvpp.template_version_preset_id, tvpp.name, tvpp.value
|
||||
FROM
|
||||
template_version_preset_parameters tvpp
|
||||
WHERE
|
||||
tvpp.template_version_preset_id = $1
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetPresetParametersByPresetID(ctx context.Context, presetID uuid.UUID) ([]TemplateVersionPresetParameter, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getPresetParametersByPresetID, presetID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []TemplateVersionPresetParameter
|
||||
for rows.Next() {
|
||||
var i TemplateVersionPresetParameter
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.TemplateVersionPresetID,
|
||||
&i.Name,
|
||||
&i.Value,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getPresetParametersByTemplateVersionID = `-- name: GetPresetParametersByTemplateVersionID :many
|
||||
SELECT
|
||||
template_version_preset_parameters.id, template_version_preset_parameters.template_version_preset_id, template_version_preset_parameters.name, template_version_preset_parameters.value
|
||||
|
||||
Reference in New Issue
Block a user