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

@ -17,6 +17,8 @@ type CreateVPCCommand struct {
CIDR string
}
func (c CreateVPCCommand) Key() string { return "vpc/" + c.Name }
func (c CreateVPCCommand) Prepare(db *badger.DB, _ *configuration.Config) error {
if _, err := kv.GetFromDB(db, "vpc/"+c.Name+"/state"); err == nil {
return fmt.Errorf("vpc %q already exists", c.Name)
@ -38,6 +40,8 @@ type DeleteVPCCommand struct {
Name string
}
func (c DeleteVPCCommand) Key() string { return "vpc/" + c.Name }
func (c DeleteVPCCommand) Prepare(db *badger.DB, _ *configuration.Config) error {
if _, err := kv.GetFromDB(db, "vpc/"+c.Name+"/state"); err != nil {
return fmt.Errorf("vpc %q not found", c.Name)