mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-02 03:33:05 +00:00
Move context per cure's suggestion
This commit is contained in:
parent
3f30bf1e33
commit
12f2a7cee0
2 changed files with 5 additions and 9 deletions
|
@ -38,14 +38,14 @@ var createNamespaceCmd = &cobra.Command{
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
o, _ := cmd.Flags().GetString("output")
|
o, _ := cmd.Flags().GetString("output")
|
||||||
|
|
||||||
client, conn := getHeadscaleGRPCClient()
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
client, conn := getHeadscaleGRPCClient(ctx)
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
log.Trace().Interface("client", client).Msg("Obtained gRPC client")
|
log.Trace().Interface("client", client).Msg("Obtained gRPC client")
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
request := &apiV1.CreateNamespaceRequest{Name: args[0]}
|
request := &apiV1.CreateNamespaceRequest{Name: args[0]}
|
||||||
|
|
||||||
log.Trace().Interface("request", request).Msg("Sending CreateNamespace request")
|
log.Trace().Interface("request", request).Msg("Sending CreateNamespace request")
|
||||||
|
|
|
@ -316,11 +316,7 @@ func getHeadscaleApp() (*headscale.Headscale, error) {
|
||||||
return h, nil
|
return h, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getHeadscaleGRPCClient() (apiV1.HeadscaleServiceClient, *grpc.ClientConn) {
|
func getHeadscaleGRPCClient(ctx context.Context) (apiV1.HeadscaleServiceClient, *grpc.ClientConn) {
|
||||||
// TODO(kradalby): Make configurable
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
grpcOptions := []grpc.DialOption{
|
grpcOptions := []grpc.DialOption{
|
||||||
grpc.WithBlock(),
|
grpc.WithBlock(),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue