forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cancel_task.go
46 lines (35 loc) · 976 Bytes
/
cancel_task.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package action
import (
"errors"
boshtask "github.com/cloudfoundry/bosh-agent/agent/task"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
)
type CancelTaskAction struct {
taskService boshtask.Service
}
func NewCancelTask(taskService boshtask.Service) (getTask CancelTaskAction) {
getTask.taskService = taskService
return
}
func (a CancelTaskAction) IsAsynchronous(_ ProtocolVersion) bool {
return false
}
func (a CancelTaskAction) IsPersistent() bool {
return false
}
func (a CancelTaskAction) IsLoggable() bool {
return true
}
func (a CancelTaskAction) Run(taskID string) (string, error) {
task, found := a.taskService.FindTaskWithID(taskID)
if !found {
return "", bosherr.Errorf("Task with id %s could not be found", taskID)
}
return "canceled", task.Cancel()
}
func (a CancelTaskAction) Resume() (interface{}, error) {
return nil, errors.New("not supported")
}
func (a CancelTaskAction) Cancel() error {
return errors.New("not supported")
}