mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 00:09:40 +02:00
feat(edge): edgeStacks and edgeJobs operations small refactors [EE-2744] (#6648)
This commit is contained in:
parent
6419e7740a
commit
f12c3968f1
9 changed files with 52 additions and 59 deletions
|
@ -92,7 +92,7 @@ func (handler *Handler) updateEdgeSchedule(edgeJob *portainer.EdgeJob, payload *
|
|||
continue
|
||||
}
|
||||
|
||||
if meta, ok := edgeJob.Endpoints[endpointID]; ok {
|
||||
if meta, exists := edgeJob.Endpoints[endpointID]; exists {
|
||||
endpointsMap[endpointID] = meta
|
||||
} else {
|
||||
endpointsMap[endpointID] = portainer.EdgeJobEndpointMeta{}
|
||||
|
@ -103,13 +103,18 @@ func (handler *Handler) updateEdgeSchedule(edgeJob *portainer.EdgeJob, payload *
|
|||
}
|
||||
|
||||
updateVersion := false
|
||||
if payload.CronExpression != nil {
|
||||
if payload.CronExpression != nil && *payload.CronExpression != edgeJob.CronExpression {
|
||||
edgeJob.CronExpression = *payload.CronExpression
|
||||
updateVersion = true
|
||||
}
|
||||
|
||||
if payload.FileContent != nil {
|
||||
_, err := handler.FileService.StoreEdgeJobFileFromBytes(strconv.Itoa(int(edgeJob.ID)), []byte(*payload.FileContent))
|
||||
fileContent, err := handler.FileService.GetFileContent(edgeJob.ScriptPath, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if payload.FileContent != nil && *payload.FileContent != string(fileContent) {
|
||||
_, err := handler.FileService.StoreEdgeJobFileFromBytes(strconv.Itoa(int(edgeJob.ID)), fileContent)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -117,7 +122,7 @@ func (handler *Handler) updateEdgeSchedule(edgeJob *portainer.EdgeJob, payload *
|
|||
updateVersion = true
|
||||
}
|
||||
|
||||
if payload.Recurring != nil {
|
||||
if payload.Recurring != nil && *payload.Recurring != edgeJob.Recurring {
|
||||
edgeJob.Recurring = *payload.Recurring
|
||||
updateVersion = true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue