Skip to content

Commit

Permalink
git mv the scheduler code from filesystem/ to edge/scheduler/
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Dowideit <[email protected]>
  • Loading branch information
SvenDowideit committed Jan 25, 2022
1 parent 953c720 commit 5701949
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions edge/poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/portainer/agent/edge/scheduler"
"log"
"net/http"
"strconv"
"time"

"github.com/portainer/agent"
"github.com/portainer/agent/chisel"
"github.com/portainer/agent/filesystem"
"github.com/portainer/libcrypto"
)

Expand Down Expand Up @@ -74,7 +74,7 @@ func newPollService(edgeStackManager *StackManager, logsManager *logsManager, co
insecurePoll: config.InsecurePoll,
inactivityTimeout: inactivityTimeout,
tunnelClient: chisel.NewClient(),
scheduleManager: filesystem.NewCronManager(),
scheduleManager: scheduler.NewCronManager(),
refreshSignal: nil,
edgeStackManager: edgeStackManager,
portainerURL: config.PortainerURL,
Expand Down
10 changes: 6 additions & 4 deletions filesystem/scheduler.go → edge/scheduler/scheduler.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//go:build !windows
// +build !windows

package filesystem
package scheduler

import (
"encoding/base64"
"fmt"
"github.com/portainer/agent/filesystem"
"log"
"strings"

Expand Down Expand Up @@ -42,7 +44,7 @@ func (manager *CronManager) Schedule(schedules []agent.Schedule) error {
if manager.cronFileExists {
log.Println("[DEBUG] [filesystem,cron] [message: no schedules available, removing cron file]")
manager.cronFileExists = false
return RemoveFile(fmt.Sprintf("%s%s/%s", agent.HostRoot, cronDirectory, cronFile))
return filesystem.RemoveFile(fmt.Sprintf("%s%s/%s", agent.HostRoot, cronDirectory, cronFile))
}
return nil
}
Expand Down Expand Up @@ -81,7 +83,7 @@ func createCronEntry(schedule *agent.Schedule) (string, error) {
return "", err
}

err = WriteFile(fmt.Sprintf("%s%s", agent.HostRoot, agent.ScheduleScriptDirectory), fmt.Sprintf("schedule_%d", schedule.ID), []byte(decodedScript), 0744)
err = filesystem.WriteFile(fmt.Sprintf("%s%s", agent.HostRoot, agent.ScheduleScriptDirectory), fmt.Sprintf("schedule_%d", schedule.ID), []byte(decodedScript), 0744)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -118,7 +120,7 @@ func (manager *CronManager) flushEntries() error {

cronEntries = append(cronEntries, "")
cronFileContent := strings.Join(cronEntries, "\n")
err := WriteFile(fmt.Sprintf("%s%s", agent.HostRoot, cronDirectory), cronFile, []byte(cronFileContent), 0644)
err := filesystem.WriteFile(fmt.Sprintf("%s%s", agent.HostRoot, cronDirectory), cronFile, []byte(cronFileContent), 0644)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//go:build windows
// +build windows

package filesystem
package scheduler

import "github.com/portainer/agent"

Expand Down

0 comments on commit 5701949

Please sign in to comment.