-
Notifications
You must be signed in to change notification settings - Fork 114
/
start.go
68 lines (55 loc) · 1.48 KB
/
start.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package action
import (
"errors"
boshappl "github.com/cloudfoundry/bosh-agent/agent/applier"
boshas "github.com/cloudfoundry/bosh-agent/agent/applier/applyspec"
boshjobsuper "github.com/cloudfoundry/bosh-agent/jobsupervisor"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
)
type StartAction struct {
jobSupervisor boshjobsuper.JobSupervisor
applier boshappl.Applier
specService boshas.V1Service
}
func NewStart(jobSupervisor boshjobsuper.JobSupervisor, applier boshappl.Applier, specService boshas.V1Service) (start StartAction) {
start = StartAction{
jobSupervisor: jobSupervisor,
specService: specService,
applier: applier,
}
return
}
func (a StartAction) IsAsynchronous(_ ProtocolVersion) bool {
return false
}
func (a StartAction) IsPersistent() bool {
return false
}
func (a StartAction) IsLoggable() bool {
return true
}
func (a StartAction) Run() (value string, err error) {
desiredApplySpec, err := a.specService.Get()
if err != nil {
err = bosherr.WrapError(err, "Getting apply spec")
return
}
err = a.applier.ConfigureJobs(desiredApplySpec)
if err != nil {
err = bosherr.WrapErrorf(err, "Configuring jobs")
return
}
err = a.jobSupervisor.Start()
if err != nil {
err = bosherr.WrapError(err, "Starting Monitored Services")
return
}
value = "started"
return
}
func (a StartAction) Resume() (interface{}, error) {
return nil, errors.New("not supported")
}
func (a StartAction) Cancel() error {
return errors.New("not supported")
}