mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 20:35:24 +01:00
fix(backup): export/import survay_variables
This commit is contained in:
parent
2a8f7cf884
commit
a28cfd2908
@ -37,17 +37,17 @@ const (
|
||||
)
|
||||
|
||||
type SurveyVarEnumValue struct {
|
||||
Name string `json:"name"`
|
||||
Value string `json:"value"`
|
||||
Name string `json:"name" backup:"name"`
|
||||
Value string `json:"value" backup:"value"`
|
||||
}
|
||||
|
||||
type SurveyVar struct {
|
||||
Name string `json:"name"`
|
||||
Title string `json:"title"`
|
||||
Required bool `json:"required"`
|
||||
Type SurveyVarType `json:"type"`
|
||||
Description string `json:"description"`
|
||||
Values []SurveyVarEnumValue `json:"values"`
|
||||
Name string `json:"name" backup:"name"`
|
||||
Title string `json:"title" backup:"title"`
|
||||
Required bool `json:"required" backup:"required"`
|
||||
Type SurveyVarType `json:"type" backup:"type"`
|
||||
Description string `json:"description" backup:"description"`
|
||||
Values []SurveyVarEnumValue `json:"values" backup:"values"`
|
||||
}
|
||||
|
||||
type TemplateFilter struct {
|
||||
@ -94,8 +94,8 @@ type Template struct {
|
||||
// SurveyVarsJSON used internally for read from database.
|
||||
// It is not used for store survey vars to database.
|
||||
// Do not use it in your code. Use SurveyVars instead.
|
||||
SurveyVarsJSON *string `db:"survey_vars" json:"-"`
|
||||
SurveyVars []SurveyVar `db:"-" json:"survey_vars" backup:"-"`
|
||||
SurveyVarsJSON *string `db:"survey_vars" json:"-" backup:"-"`
|
||||
SurveyVars []SurveyVar `db:"-" json:"survey_vars" backup:"survey_vars"`
|
||||
|
||||
SuppressSuccessAlerts bool `db:"suppress_success_alerts" json:"suppress_success_alerts"`
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
package bolt
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"github.com/ansible-semaphore/semaphore/db"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
@ -67,7 +69,15 @@ func (d *BoltDb) GetTemplates(projectID int, filter db.TemplateFilter, params db
|
||||
templatesMap := make(map[int]*db.Template)
|
||||
|
||||
for i := 0; i < len(templates); i++ {
|
||||
templates[i].Vaults, err = d.GetTemplateVaults(projectID, templates[i].ID)
|
||||
|
||||
if templates[i].SurveyVarsJSON != nil {
|
||||
err = json.Unmarshal([]byte(*templates[i].SurveyVarsJSON), &templates[i].SurveyVars)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
templatesMap[templates[i].ID] = &templates[i]
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package sql
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/ansible-semaphore/semaphore/db"
|
||||
@ -228,7 +229,10 @@ func (d *SqlDb) GetTemplates(projectID int, filter db.TemplateFilter, params db.
|
||||
}
|
||||
}
|
||||
|
||||
template.Vaults, err = d.GetTemplateVaults(projectID, template.ID)
|
||||
if tpl.SurveyVarsJSON != nil {
|
||||
err = json.Unmarshal([]byte(*tpl.SurveyVarsJSON), &tpl.SurveyVars)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user