use switch

This commit is contained in:
wh1te909 2023-12-01 11:27:28 -08:00
parent db17e3e28e
commit 060d222941

View File

@ -175,16 +175,17 @@ func (a *Agent) CreateSchedTask(st SchedTask) (bool, error) {
var tasktrigger taskmaster.TaskTrigger var tasktrigger taskmaster.TaskTrigger
var now = time.Now() var now = time.Now()
if st.Trigger == "manual" { switch st.Trigger {
case "manual":
tasktrigger = taskmaster.TaskTrigger{ tasktrigger = taskmaster.TaskTrigger{
Enabled: st.Enabled, Enabled: st.Enabled,
StartBoundary: now, StartBoundary: now,
} }
} else if st.Trigger == "onboarding" { case "onboarding":
tasktrigger = taskmaster.TaskTrigger{ tasktrigger = taskmaster.TaskTrigger{
Enabled: st.Enabled, Enabled: st.Enabled,
} }
} else { default:
tasktrigger = taskmaster.TaskTrigger{ tasktrigger = taskmaster.TaskTrigger{
Enabled: st.Enabled, Enabled: st.Enabled,
StartBoundary: time.Date(st.StartYear, st.StartMonth, st.StartDay, st.StartHour, st.StartMinute, 0, 0, now.Location()), StartBoundary: time.Date(st.StartYear, st.StartMonth, st.StartDay, st.StartHour, st.StartMinute, 0, 0, now.Location()),
@ -209,7 +210,6 @@ func (a *Agent) CreateSchedTask(st SchedTask) (bool, error) {
TaskTrigger: tasktrigger, TaskTrigger: tasktrigger,
RandomDelay: st.RandomDelay, RandomDelay: st.RandomDelay,
} }
case "onboarding": case "onboarding":
trigger = taskmaster.RegistrationTrigger{ trigger = taskmaster.RegistrationTrigger{
TaskTrigger: tasktrigger, TaskTrigger: tasktrigger,