(fs boshsys.FileSystem, path string)
| 18 | } |
| 19 | |
| 20 | func 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 | |
| 40 | func (s *BootstrapState) SaveState() (err error) { |
| 41 | jsonState, err := json.Marshal(*s) |
no test coverage detected