natlab: add NodeAgentClient

This adds a new NodeAgentClient type that can be used to
invoke the LocalAPI using the LocalClient instead of
handcrafted URLs. However, there are certain cases where
it does make sense for the node agent to provide more
functionality than whats possible with just the LocalClient,
as such it also exposes a http.Client to make requests directly.

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali
2024-08-07 21:31:50 -07:00
committed by Maisem Ali
parent 1016aa045f
commit 12764e9db4
4 changed files with 56 additions and 101 deletions

View File

@@ -68,12 +68,12 @@ func main() {
}
s.WriteStartingBanner(os.Stdout)
nc := s.NodeAgentClient(node1)
go func() {
getStatus := func() {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
st, err := s.NodeStatus(ctx, node1)
st, err := nc.Status(ctx)
if err != nil {
log.Printf("NodeStatus: %v", err)
return