func getGuestsFWGroups(c *ln.Context, hv *ln.Hypervisor) (groupMap, guestMap) { guests := guestMap{} groups := groupMap{} n := len(groups) _ = hv.ForEachGuest(func(guest *ln.Guest) error { // check if in cache g, ok := groups[guest.FWGroupID] if ok { // link the guest to the FWGroup, via the FWGroup's index guests[guest.IP.String()] = g.num return nil } // nope not cached fw, err := c.FWGroup(guest.FWGroupID) if err != nil { log.WithFields(log.Fields{ "error": err, "func": "context.FWGroup", "group": guest.FWGroupID, }).Error("failed to get firewall group") return err } g = groupVal{ num: n, id: fw.ID, rules: genNFRules(groups, fw.Rules), } n++ groups[guest.FWGroupID] = g // link the guest to the FWGroup, via the FWGroup's index guests[guest.IP.String()] = g.num return nil }) return groups, guests }