mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-12-04 15:21:05 +01:00
fix(be): null pointer in new task params field
This commit is contained in:
parent
289cd6d937
commit
89c9042d1e
26
db/Task.go
26
db/Task.go
@ -67,19 +67,35 @@ type Task struct {
|
||||
|
||||
InventoryID *int `db:"inventory_id" json:"inventory_id"`
|
||||
|
||||
TaskParams MapStringAnyField `db:"params" json:"params"`
|
||||
Params MapStringAnyField `db:"params" json:"params"`
|
||||
}
|
||||
|
||||
func (task *Task) GetParams(target interface{}) error {
|
||||
content, err := json.Marshal(task.TaskParams)
|
||||
func (task *Task) GetParams(target interface{}) (err error) {
|
||||
content, err := json.Marshal(task.Params)
|
||||
if err != nil {
|
||||
return err
|
||||
return
|
||||
}
|
||||
return json.Unmarshal(content, target)
|
||||
err = json.Unmarshal(content, target)
|
||||
return
|
||||
}
|
||||
|
||||
func (task *Task) PreInsert(gorp.SqlExecutor) error {
|
||||
task.Created = task.Created.UTC()
|
||||
|
||||
// Init params from old fields for backward compatibility
|
||||
|
||||
if task.Debug {
|
||||
task.Params["debug"] = true
|
||||
}
|
||||
|
||||
if task.DryRun {
|
||||
task.Params["dry_run"] = true
|
||||
}
|
||||
|
||||
if task.Diff {
|
||||
task.Params["diff"] = true
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -102,6 +102,8 @@ type Template struct {
|
||||
App TemplateApp `db:"app" json:"app"`
|
||||
|
||||
Tasks int `db:"tasks" json:"tasks" backup:"-"`
|
||||
|
||||
TaskParams MapStringAnyField `db:"task_params" json:"task_params"`
|
||||
}
|
||||
|
||||
func (tpl *Template) Validate() error {
|
||||
|
@ -431,13 +431,13 @@ func (t *LocalJob) Run(username string, incomingVersion *string) (err error) {
|
||||
switch t.Template.App {
|
||||
case db.AppAnsible:
|
||||
args, inputs, err = t.getPlaybookArgs(username, incomingVersion)
|
||||
params = db.AnsibleTaskParams{}
|
||||
params = &db.AnsibleTaskParams{}
|
||||
case db.AppTerraform, db.AppTofu:
|
||||
args, err = t.getTerraformArgs(username, incomingVersion)
|
||||
params = db.TerraformTaskParams{}
|
||||
params = &db.TerraformTaskParams{}
|
||||
default:
|
||||
args, err = t.getShellArgs(username, incomingVersion)
|
||||
params = db.DefaultTaskParams{}
|
||||
params = &db.DefaultTaskParams{}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
@ -262,11 +262,11 @@ export default {
|
||||
responseType: 'json',
|
||||
})).data;
|
||||
|
||||
this.user = (await axios({
|
||||
this.user = this.item.user_id ? (await axios({
|
||||
method: 'get',
|
||||
url: `/api/users/${this.item.user_id}`,
|
||||
responseType: 'json',
|
||||
})).data;
|
||||
})).data : null;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user