Add get ips command to scenario

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
Kristoffer Dalby committed 2022-10-18 15:37:11 +02:00
1 parent f109b54e79
commit 25e39d9ff9
2 files changed
+31 -3

No files matched your search

+18
View File
@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"log"
"net/netip"
"os"
"sync"
@@ -210,3 +211,20 @@ func (s *Scenario) RunTailscaleUp(
return fmt.Errorf("failed to up tailscale node: %w", errNoNamespaceAvailable)
}
func (s *Scenario) GetIPs(namespace string) ([]netip.Addr, error) {
var ips []netip.Addr
if ns, ok := s.namespaces[namespace]; ok {
for _, client := range ns.Clients {
clientIps, err := client.IPs()
if err != nil {
return ips, fmt.Errorf("failed to get ips: %w", err)
}
ips = append(ips, clientIps...)
}
return ips, nil
}
return ips, fmt.Errorf("failed to get ips: %w", errNoNamespaceAvailable)
}