f-37: code: add state error in return nil #37

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-08-13 23:12:32 +02:00
commit fa72b6cd47
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
4 changed files with 18 additions and 0 deletions

View file

@ -30,6 +30,8 @@ type StartVMCommand struct {
SSHKey string
}
func (c StartVMCommand) Key() string { return "vm/" + c.Name }
func (c StartVMCommand) Prepare(db *badger.DB, _ *configuration.Config) error {
if _, err := kv.GetFromDB(db, "vm/"+c.Name+"/state"); err == nil {
return fmt.Errorf("vm %q already exists", c.Name)
@ -111,6 +113,8 @@ type StopVMCommand struct {
Name string
}
func (c StopVMCommand) Key() string { return "vm/" + c.Name }
func (c StopVMCommand) Prepare(db *badger.DB, _ *configuration.Config) error {
if _, err := kv.GetFromDB(db, "vm/"+c.Name+"/state"); err != nil {
return fmt.Errorf("vm %q not found", c.Name)