metropolis/cli/pkg/context: replace with signal.NotifyContext
Change-Id: I457ccb83c7e25988755bb9463a8c83fc328a722b
Reviewed-on: https://review.monogon.dev/c/monogon/+/3081
Tested-by: Jenkins CI
Reviewed-by: Serge Bazanski <serge@monogon.tech>
diff --git a/metropolis/cli/metroctl/cmd_node.go b/metropolis/cli/metroctl/cmd_node.go
index ebfaa25..19440b6 100644
--- a/metropolis/cli/metroctl/cmd_node.go
+++ b/metropolis/cli/metroctl/cmd_node.go
@@ -7,6 +7,7 @@
"io"
"log"
"os"
+ "os/signal"
"strings"
"sync"
"time"
@@ -16,7 +17,6 @@
"source.monogon.dev/go/clitable"
"source.monogon.dev/metropolis/cli/metroctl/core"
- clicontext "source.monogon.dev/metropolis/cli/pkg/context"
"source.monogon.dev/metropolis/node/core/identity"
"source.monogon.dev/version"
@@ -33,7 +33,7 @@
Use: "describe [node-id] [--filter] [--output] [--format]",
Example: "metroctl node describe metropolis-c556e31c3fa2bf0a36e9ccb9fd5d6056",
Run: func(cmd *cobra.Command, args []string) {
- ctx := clicontext.WithInterrupt(context.Background())
+ ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt)
cc := dialAuthenticated(ctx)
mgmt := apb.NewManagementClient(cc)
@@ -52,7 +52,7 @@
Use: "list [node-id] [--filter] [--output] [--format]",
Example: "metroctl node list --filter node.status.external_address==\"10.8.0.2\"",
Run: func(cmd *cobra.Command, args []string) {
- ctx := clicontext.WithInterrupt(context.Background())
+ ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt)
cc := dialAuthenticated(ctx)
mgmt := apb.NewManagementClient(cc)
@@ -106,7 +106,7 @@
}
unavailableSemaphore := semaphore.NewWeighted(int64(maxUnavailable))
- ctx := clicontext.WithInterrupt(context.Background())
+ ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt)
cacert, err := core.GetClusterCAWithTOFU(ctx, connectOptions())
if err != nil {
@@ -234,7 +234,7 @@
return err
}
- ctx := clicontext.WithInterrupt(context.Background())
+ ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt)
mgmt := apb.NewManagementClient(dialAuthenticated(ctx))
nodes, err := core.GetNodes(ctx, mgmt, fmt.Sprintf("node.id==%q", args[0]))