MCPcopy Create free account
hub / github.com/cloudfoundry/bosh-agent / NewBootstrapState

Function NewBootstrapState

platform/bootstrap_state.go:20–38  ·  view source on GitHub ↗
(fs boshsys.FileSystem, path string)

Source from the content-addressed store, hash-verified

18}
19
20func NewBootstrapState(fs boshsys.FileSystem, path string) (*BootstrapState, error) {
21 state := BootstrapState{fs: fs, path: path}
22
23 if !fs.FileExists(path) {
24 return &state, nil
25 }
26
27 bytes, err := fs.ReadFile(path)
28 if err != nil {
29 return nil, bosherr.WrapError(err, "Reading bootstrap state file")
30 }
31
32 err = json.Unmarshal(bytes, &state)
33 if err != nil {
34 return nil, bosherr.WrapError(err, "Unmarshalling bootstrap state")
35 }
36
37 return &state, nil
38}
39
40func (s *BootstrapState) SaveState() (err error) {
41 jsonState, err := json.Marshal(*s)

Callers 2

Calls 2

FileExistsMethod · 0.80
UnmarshalMethod · 0.65

Tested by

no test coverage detected