Skip to content

Commit

Permalink
fix multi-platform field renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
creativeprojects committed Sep 25, 2023
1 parent 75cb443 commit 4c8799c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions schedule/handler_crond.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func (h *HandlerCrond) CreateJob(job *config.ScheduleConfig, schedules []*calend
entries[i] = crond.NewEntry(
event,
job.ConfigFile,
job.Title,
job.SubTitle,
job.ProfileName,
job.CommandName,
job.Command+" "+strings.Join(job.Arguments, " "),
job.WorkingDirectory,
)
Expand All @@ -80,8 +80,8 @@ func (h *HandlerCrond) RemoveJob(job *config.ScheduleConfig, permission string)
crond.NewEntry(
calendar.NewEvent(),
job.ConfigFile,
job.Title,
job.SubTitle,
job.ProfileName,
job.CommandName,
job.Command+" "+strings.Join(job.Arguments, " "),
job.WorkingDirectory,
),
Expand Down
12 changes: 6 additions & 6 deletions schedule/handler_systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ func (h *HandlerSystemd) CreateJob(job *config.ScheduleConfig, schedules []*cale
CommandLine: job.Command + " --no-prio " + strings.Join(job.Arguments, " "),
Environment: job.Environment,
WorkingDirectory: job.WorkingDirectory,
Title: job.Title,
SubTitle: job.SubTitle,
Title: job.ProfileName,
SubTitle: job.CommandName,
JobDescription: job.JobDescription,
TimerDescription: job.TimerDescription,
Schedules: job.Schedules,
Expand All @@ -134,7 +134,7 @@ func (h *HandlerSystemd) CreateJob(job *config.ScheduleConfig, schedules []*cale
}
}

timerName := systemd.GetTimerFile(job.Title, job.SubTitle)
timerName := systemd.GetTimerFile(job.ProfileName, job.CommandName)

// enable the job
err = runSystemctlCommand(timerName, systemctlEnable, unitType, false)
Expand Down Expand Up @@ -164,7 +164,7 @@ func (h *HandlerSystemd) RemoveJob(job *config.ScheduleConfig, permission string
unitType = systemd.SystemUnit
}
var err error
timerFile := systemd.GetTimerFile(job.Title, job.SubTitle)
timerFile := systemd.GetTimerFile(job.ProfileName, job.CommandName)

// stop the job
err = runSystemctlCommand(timerFile, systemctlStop, unitType, job.RemoveOnly)
Expand All @@ -191,7 +191,7 @@ func (h *HandlerSystemd) RemoveJob(job *config.ScheduleConfig, permission string
return nil
}

serviceFile := systemd.GetServiceFile(job.Title, job.SubTitle)
serviceFile := systemd.GetServiceFile(job.ProfileName, job.CommandName)
err = os.Remove(path.Join(systemdPath, serviceFile))
if err != nil {
return nil
Expand All @@ -202,7 +202,7 @@ func (h *HandlerSystemd) RemoveJob(job *config.ScheduleConfig, permission string

// DisplayJobStatus displays information of a systemd service/timer
func (h *HandlerSystemd) DisplayJobStatus(job *config.ScheduleConfig) error {
timerName := systemd.GetTimerFile(job.Title, job.SubTitle)
timerName := systemd.GetTimerFile(job.ProfileName, job.CommandName)
permission := getSchedulePermission(job.Permission)
if permission == constants.SchedulePermissionSystem {
err := runJournalCtlCommand(timerName, systemd.SystemUnit)
Expand Down
4 changes: 2 additions & 2 deletions schedule/handler_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (h *HandlerWindows) CreateJob(job *config.ScheduleConfig, schedules []*cale

// RemoveJob is deleting the task scheduler job
func (h *HandlerWindows) RemoveJob(job *config.ScheduleConfig, permission string) error {
err := schtasks.Delete(job.Title, job.SubTitle)
err := schtasks.Delete(job.ProfileName, job.CommandName)
if err != nil {
if errors.Is(err, schtasks.ErrorNotRegistered) {
return ErrorServiceNotFound
Expand All @@ -83,7 +83,7 @@ func (h *HandlerWindows) RemoveJob(job *config.ScheduleConfig, permission string

// DisplayStatus display some information about the task scheduler job
func (h *HandlerWindows) DisplayJobStatus(job *config.ScheduleConfig) error {
err := schtasks.Status(job.Title, job.SubTitle)
err := schtasks.Status(job.ProfileName, job.CommandName)
if err != nil {
if errors.Is(err, schtasks.ErrorNotRegistered) {
return ErrorServiceNotFound
Expand Down
12 changes: 6 additions & 6 deletions schtasks/taskscheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func Create(config *config.ScheduleConfig, schedules []*calendar.Event, permissi

// createUserTask creates a new user task. Will update an existing task instead of overwritting
func createUserTask(config *config.ScheduleConfig, schedules []*calendar.Event) error {
taskName := getTaskPath(config.Title, config.SubTitle)
taskName := getTaskPath(config.ProfileName, config.CommandName)
registeredTask, err := taskService.GetRegisteredTask(taskName)
if err == nil {
// the task already exists
Expand Down Expand Up @@ -145,7 +145,7 @@ func createUserTask(config *config.ScheduleConfig, schedules []*calendar.Event)

// updateUserTask updates an existing task
func updateUserTask(task taskmaster.RegisteredTask, config *config.ScheduleConfig, schedules []*calendar.Event) error {
taskName := getTaskPath(config.Title, config.SubTitle)
taskName := getTaskPath(config.ProfileName, config.CommandName)

username, password, err := userCredentials()
if err != nil {
Expand Down Expand Up @@ -202,7 +202,7 @@ func userCredentials() (string, string, error) {

// createUserLoggedOnTask creates a new user task. Will update an existing task instead of overwritting
func createUserLoggedOnTask(config *config.ScheduleConfig, schedules []*calendar.Event) error {
taskName := getTaskPath(config.Title, config.SubTitle)
taskName := getTaskPath(config.ProfileName, config.CommandName)
registeredTask, err := taskService.GetRegisteredTask(taskName)
if err == nil {
// the task already exists
Expand Down Expand Up @@ -240,7 +240,7 @@ func createUserLoggedOnTask(config *config.ScheduleConfig, schedules []*calendar

// updateUserLoggedOnTask updates an existing task
func updateUserLoggedOnTask(task taskmaster.RegisteredTask, config *config.ScheduleConfig, schedules []*calendar.Event) error {
taskName := getTaskPath(config.Title, config.SubTitle)
taskName := getTaskPath(config.ProfileName, config.CommandName)

// clear up all actions and put ours back
task.Definition.Actions = make([]taskmaster.Action, 0, 1)
Expand Down Expand Up @@ -270,7 +270,7 @@ func updateUserLoggedOnTask(task taskmaster.RegisteredTask, config *config.Sched

// createSystemTask creates a new system task. Will update an existing task instead of overwritting
func createSystemTask(config *config.ScheduleConfig, schedules []*calendar.Event) error {
taskName := getTaskPath(config.Title, config.SubTitle)
taskName := getTaskPath(config.ProfileName, config.CommandName)
registeredTask, err := taskService.GetRegisteredTask(taskName)
if err == nil {
// the task already exists
Expand Down Expand Up @@ -303,7 +303,7 @@ func createSystemTask(config *config.ScheduleConfig, schedules []*calendar.Event

// updateSystemTask updates an existing task
func updateSystemTask(task taskmaster.RegisteredTask, config *config.ScheduleConfig, schedules []*calendar.Event) error {
taskName := getTaskPath(config.Title, config.SubTitle)
taskName := getTaskPath(config.ProfileName, config.CommandName)

// clear up all actions and put ours back
task.Definition.Actions = make([]taskmaster.Action, 0, 1)
Expand Down

0 comments on commit 4c8799c

Please sign in to comment.