mirror of
https://github.com/juanfont/headscale.git
synced 2026-02-07 20:04:00 +01:00
16 lines
384 B
Go
16 lines
384 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
|
)
|
|
|
|
// WithClient handles gRPC client setup and cleanup, calls fn with client and context
|
|
func WithClient(fn func(context.Context, v1.HeadscaleServiceClient) error) error {
|
|
ctx, client, conn, cancel := newHeadscaleCLIWithConfig()
|
|
defer cancel()
|
|
defer conn.Close()
|
|
|
|
return fn(ctx, client)
|
|
} |