f-42: api: ressource /nat-gateways, état, métrique et watchdog #42

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-10-29 20:25:52 +01:00
commit 2737b61bc4
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
16 changed files with 841 additions and 11 deletions

View file

@ -232,6 +232,20 @@ func expectedExports(db *badger.DB, vpcName string) (expected, tolerated map[str
classify(st, ip.String()+"/32")
}
}
gateways, err := kv.ListByPrefix(db, prefixNATGW)
if err != nil {
return nil, nil, fmt.Errorf("watchdog: listing nat gateways: %w", err)
}
for key, value := range gateways {
name, ok := strings.CutSuffix(strings.TrimPrefix(key, prefixNATGW), "/vpc")
if !ok || strings.Contains(name, "/") || value != vpcName {
continue
}
if st, err := state.Get(db, prefixNATGW+name); err == nil {
classify(st, "0.0.0.0/0")
}
}
return expected, tolerated, nil
}