f-21: code: swap from interface only to full conf

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-04-21 21:32:59 +02:00
commit 8a68d3818f
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
4 changed files with 16 additions and 13 deletions

View file

@ -5,6 +5,7 @@ import (
"os"
"strconv"
configuration "git.g3e.fr/syonad/two/internal/config/agent"
"git.g3e.fr/syonad/two/internal/subnet"
"git.g3e.fr/syonad/two/pkg/db/kv"
"github.com/dgraph-io/badger/v4"
@ -19,8 +20,8 @@ type CreateSubnetCommand struct {
CIDR string
}
func (c CreateSubnetCommand) Execute(db *badger.DB, interfaces map[string]string) error {
localIface, ok := interfaces[c.IfaceType]
func (c CreateSubnetCommand) Execute(db *badger.DB, cfg *configuration.Config) error {
localIface, ok := cfg.Interfaces[c.IfaceType]
if !ok {
return fmt.Errorf("unknown iface_type %q: not found in config", c.IfaceType)
}
@ -37,7 +38,7 @@ type DeleteSubnetCommand struct {
Name string
}
func (c DeleteSubnetCommand) Execute(db *badger.DB, _ map[string]string) error {
func (c DeleteSubnetCommand) Execute(db *badger.DB, _ *configuration.Config) error {
kv.AddInDB(db, "subnet/"+c.Name+"/state", "deleting")
if err := subnet.DeleteSubnet(db, c.Name); err != nil {
fmt.Println(err)