Added env to scripts
This commit is contained in:
parent
9514628710
commit
5145830f65
3 changed files with 60 additions and 19 deletions
|
|
@ -27,6 +27,7 @@ type Hook struct {
|
|||
Node Node
|
||||
Script Script
|
||||
SSH string
|
||||
Env map[string]string
|
||||
}
|
||||
|
||||
func GetScript(scriptID int) (script Script, err error) { // {{{
|
||||
|
|
@ -161,7 +162,7 @@ func SearchScripts(search string) (scripts []Script, err error) { // {{{
|
|||
return
|
||||
} // }}}
|
||||
func HookScript(nodeID, scriptID int) (err error) { // {{{
|
||||
_, err = db.Exec(`INSERT INTO hook(node_id, script_id, ssh) VALUES($1, $2, '<host>')`, nodeID, scriptID)
|
||||
_, err = db.Exec(`INSERT INTO hook(node_id, script_id, ssh, env) VALUES($1, $2, '<host>')`, nodeID, scriptID)
|
||||
return
|
||||
} // }}}
|
||||
|
||||
|
|
@ -173,6 +174,7 @@ func GetHook(hookID int) (hook Hook, err error) { // {{{
|
|||
SELECT
|
||||
h.id,
|
||||
h.ssh,
|
||||
h.env,
|
||||
(SELECT to_json(node) FROM node WHERE id = h.node_id) AS node,
|
||||
(SELECT to_json(script) FROM script WHERE id = h.script_id) AS script
|
||||
FROM hook h
|
||||
|
|
@ -243,7 +245,8 @@ func ScheduleHook(hookID int) (err error) { // {{{
|
|||
return
|
||||
}
|
||||
|
||||
_, err = db.Exec(`INSERT INTO execution(script_log_id, data, ssh) VALUES($1, $2, $3)`, scriptLogID, nodeData, hook.SSH)
|
||||
j, _ := json.Marshal(hook.Env)
|
||||
_, err = db.Exec(`INSERT INTO execution(script_log_id, data, ssh, env) VALUES($1, $2, $3, $4)`, scriptLogID, nodeData, hook.SSH, j)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue