fix(be): vault_key_id store to sql

This commit is contained in:
Denis Gukov 2021-09-17 03:14:35 +05:00
parent a9c04117c5
commit f8b0195f88

View File

@ -10,8 +10,8 @@ func (d *SqlDb) CreateTemplate(template db.Template) (newTemplate db.Template, e
insertID, err := d.insert(
"id",
"insert into project__template (project_id, inventory_id, repository_id, environment_id, " +
"alias, playbook, arguments, override_args, description)" +
"values (?, ?, ?, ?, ?, ?, ?, ?, ?)",
"alias, playbook, arguments, override_args, description, vault_key_id)" +
"values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
template.ProjectID,
template.InventoryID,
template.RepositoryID,
@ -20,7 +20,8 @@ func (d *SqlDb) CreateTemplate(template db.Template) (newTemplate db.Template, e
template.Playbook,
template.Arguments,
template.OverrideArguments,
template.Description)
template.Description,
template.VaultKeyID)
if err != nil {
return
@ -40,7 +41,7 @@ func (d *SqlDb) CreateTemplate(template db.Template) (newTemplate db.Template, e
func (d *SqlDb) UpdateTemplate(template db.Template) error {
_, err := d.exec("update project__template set inventory_id=?, repository_id=?, environment_id=?, alias=?, " +
"playbook=?, arguments=?, override_args=?, description=? " +
"playbook=?, arguments=?, override_args=?, description=?, vault_key_id=? " +
"where removed = false and id=? and project_id=?",
template.InventoryID,
template.RepositoryID,
@ -50,6 +51,7 @@ func (d *SqlDb) UpdateTemplate(template db.Template) error {
template.Arguments,
template.OverrideArguments,
template.Description,
template.VaultKeyID,
template.ID,
template.ProjectID)
return err
@ -64,7 +66,8 @@ func (d *SqlDb) GetTemplates(projectID int, params db.RetrieveQueryParams) (temp
"pt.alias",
"pt.playbook",
"pt.arguments",
"pt.override_args").
"pt.override_args",
"pt.vault_key_id").
From("project__template pt").
Where("pt.removed = false")