Skip to content

Commit 929c7e5

Browse files
committed
store: add Saved to Instance
Signed-off-by: Norio Nomura <[email protected]>
1 parent 349ccd1 commit 929c7e5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/store/instance.go

+9
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type Instance struct {
4343
// Hostname, not HostName (corresponds to SSH's naming convention)
4444
Hostname string `json:"hostname"`
4545
Status Status `json:"status"`
46+
Saved bool `json:"saved"`
4647
Dir string `json:"dir"`
4748
VMType limayaml.VMType `json:"vmType"`
4849
Arch limayaml.Arch `json:"arch"`
@@ -147,6 +148,14 @@ func Inspect(instName string) (*Instance, error) {
147148
}
148149

149150
inspectStatus(instDir, inst, y)
151+
_, err = os.Stat(filepath.Join(instDir, filenames.VzMachineState))
152+
if err == nil {
153+
inst.Saved = true
154+
} else if errors.Is(err, os.ErrNotExist) {
155+
inst.Saved = false
156+
} else {
157+
inst.Errors = append(inst.Errors, fmt.Errorf("cannot determine whether the instance is saved: %w", err))
158+
}
150159

151160
tmpl, err := template.New("format").Parse(y.Message)
152161
if err != nil {

0 commit comments

Comments
 (0)