mirror of https://github.com/portainer/portainer
feat(api): add created property for schedules (#2435)
parent
110fcc46a6
commit
7d32a6619d
|
@ -3,6 +3,7 @@ package main // import "github.com/portainer/portainer"
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/portainer/portainer"
|
"github.com/portainer/portainer"
|
||||||
"github.com/portainer/portainer/bolt"
|
"github.com/portainer/portainer/bolt"
|
||||||
|
@ -136,6 +137,7 @@ func loadSnapshotSystemSchedule(jobScheduler portainer.JobScheduler, snapshotter
|
||||||
CronExpression: "@every " + *flags.SnapshotInterval,
|
CronExpression: "@every " + *flags.SnapshotInterval,
|
||||||
JobType: portainer.SnapshotJobType,
|
JobType: portainer.SnapshotJobType,
|
||||||
SnapshotJob: snapshotJob,
|
SnapshotJob: snapshotJob,
|
||||||
|
Created: time.Now().Unix(),
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshotJobContext := cron.NewSnapshotJobContext(endpointService, snapshotter)
|
snapshotJobContext := cron.NewSnapshotJobContext(endpointService, snapshotter)
|
||||||
|
@ -173,6 +175,7 @@ func loadEndpointSyncSystemSchedule(jobScheduler portainer.JobScheduler, schedul
|
||||||
CronExpression: "@every " + *flags.SyncInterval,
|
CronExpression: "@every " + *flags.SyncInterval,
|
||||||
JobType: portainer.EndpointSyncJobType,
|
JobType: portainer.EndpointSyncJobType,
|
||||||
EndpointSyncJob: endpointSyncJob,
|
EndpointSyncJob: endpointSyncJob,
|
||||||
|
Created: time.Now().Unix(),
|
||||||
}
|
}
|
||||||
|
|
||||||
endpointSyncJobContext := cron.NewEndpointSyncJobContext(endpointService, *flags.ExternalEndpoints)
|
endpointSyncJobContext := cron.NewEndpointSyncJobContext(endpointService, *flags.ExternalEndpoints)
|
||||||
|
@ -194,6 +197,7 @@ func loadSchedulesFromDatabase(jobScheduler portainer.JobScheduler, jobService p
|
||||||
|
|
||||||
for _, schedule := range schedules {
|
for _, schedule := range schedules {
|
||||||
|
|
||||||
|
if schedule.JobType == portainer.ScriptExecutionJobType {
|
||||||
jobContext := cron.NewScriptExecutionJobContext(jobService, endpointService, fileService)
|
jobContext := cron.NewScriptExecutionJobContext(jobService, endpointService, fileService)
|
||||||
jobRunner := cron.NewScriptExecutionJobRunner(schedule.ScriptExecutionJob, jobContext)
|
jobRunner := cron.NewScriptExecutionJobRunner(schedule.ScriptExecutionJob, jobContext)
|
||||||
|
|
||||||
|
@ -202,6 +206,7 @@ func loadSchedulesFromDatabase(jobScheduler portainer.JobScheduler, jobService p
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package schedules
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/asaskevich/govalidator"
|
"github.com/asaskevich/govalidator"
|
||||||
httperror "github.com/portainer/libhttp/error"
|
httperror "github.com/portainer/libhttp/error"
|
||||||
|
@ -155,6 +156,7 @@ func (handler *Handler) createSchedule(name, image, cronExpression string, endpo
|
||||||
CronExpression: cronExpression,
|
CronExpression: cronExpression,
|
||||||
JobType: portainer.ScriptExecutionJobType,
|
JobType: portainer.ScriptExecutionJobType,
|
||||||
ScriptExecutionJob: job,
|
ScriptExecutionJob: job,
|
||||||
|
Created: time.Now().Unix(),
|
||||||
}
|
}
|
||||||
|
|
||||||
jobContext := cron.NewScriptExecutionJobContext(handler.JobService, handler.EndpointService, handler.FileService)
|
jobContext := cron.NewScriptExecutionJobContext(handler.JobService, handler.EndpointService, handler.FileService)
|
||||||
|
|
|
@ -251,6 +251,7 @@ type (
|
||||||
ID ScheduleID `json:"Id"`
|
ID ScheduleID `json:"Id"`
|
||||||
Name string
|
Name string
|
||||||
CronExpression string
|
CronExpression string
|
||||||
|
Created int64
|
||||||
JobType JobType
|
JobType JobType
|
||||||
ScriptExecutionJob *ScriptExecutionJob
|
ScriptExecutionJob *ScriptExecutionJob
|
||||||
SnapshotJob *SnapshotJob
|
SnapshotJob *SnapshotJob
|
||||||
|
|
Loading…
Reference in New Issue