Fix tests for log levels and work on adding title
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"local/firestormy/config"
|
||||
"local/firestormy/config/ns"
|
||||
"local/firestormy/logger"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -14,6 +15,7 @@ import (
|
||||
)
|
||||
|
||||
type Job struct {
|
||||
Title string
|
||||
Name string
|
||||
Schedule string
|
||||
Raw string
|
||||
@@ -34,7 +36,7 @@ func NewJob(runner Runner, schedule, raw string) (*Job, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func newBashJob(schedule, sh string) (*Job, error) {
|
||||
func newBashJob(schedule, sh string, title ...string) (*Job, error) {
|
||||
if !validCron(schedule) {
|
||||
return nil, ErrBadCron
|
||||
}
|
||||
@@ -44,6 +46,11 @@ func newBashJob(schedule, sh string) (*Job, error) {
|
||||
Raw: sh,
|
||||
Runner: Bash,
|
||||
}
|
||||
if len(title) == 0 {
|
||||
j.Title = j.Name
|
||||
} else {
|
||||
j.Title = title[0]
|
||||
}
|
||||
j.foo = func() {
|
||||
cmd := exec.Command("bash", "-c", sh)
|
||||
j.LastRun = time.Now()
|
||||
@@ -62,6 +69,7 @@ func newBashJob(schedule, sh string) (*Job, error) {
|
||||
// TODO webpage doenst load post SET despite this returning nil
|
||||
config.Store.Set(j.Name, b, ns.Jobs...)
|
||||
}
|
||||
logger.New().Info("result", fmt.Sprintf("%+v", j))
|
||||
}
|
||||
return j, nil
|
||||
}
|
||||
@@ -87,6 +95,7 @@ func (j *Job) Decode(b []byte) error {
|
||||
k, err := NewJob(j.Runner, j.Schedule, j.Raw)
|
||||
if err == nil {
|
||||
k.Name = j.Name
|
||||
k.Title = j.Title
|
||||
k.LastStatus = j.LastStatus
|
||||
k.LastOutput = j.LastOutput
|
||||
k.LastRuntime = j.LastRuntime
|
||||
|
||||
Reference in New Issue
Block a user