forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release_apply_spec.go
55 lines (43 loc) · 1.18 KB
/
release_apply_spec.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
package action
import (
"encoding/json"
"errors"
boshplatform "github.com/cloudfoundry/bosh-agent/platform"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
)
type ReleaseApplySpecAction struct {
platform boshplatform.Platform
}
func NewReleaseApplySpec(platform boshplatform.Platform) (action ReleaseApplySpecAction) {
action.platform = platform
return
}
func (a ReleaseApplySpecAction) IsAsynchronous(_ ProtocolVersion) bool {
return false
}
func (a ReleaseApplySpecAction) IsPersistent() bool {
return false
}
func (a ReleaseApplySpecAction) IsLoggable() bool {
return true
}
func (a ReleaseApplySpecAction) Run() (value interface{}, err error) {
fs := a.platform.GetFs()
specBytes, err := fs.ReadFile("/var/vcap/micro/apply_spec.json")
if err != nil {
err = bosherr.WrapError(err, "Opening micro apply spec file")
return
}
err = json.Unmarshal([]byte(specBytes), &value)
if err != nil {
err = bosherr.WrapError(err, "Unmarshalling release apply spec")
return
}
return
}
func (a ReleaseApplySpecAction) Resume() (interface{}, error) {
return nil, errors.New("not supported")
}
func (a ReleaseApplySpecAction) Cancel() error {
return errors.New("not supported")
}