MCPcopy
hub / github.com/cilium/cilium / newNodeCommand

Function newNodeCommand

hubble/cmd/list/node.go:29–67  ·  view source on GitHub ↗
(vp *viper.Viper)

Source from the content-addressed store, hash-verified

27const notAvailable = "N/A"
28
29func newNodeCommand(vp *viper.Viper) *cobra.Command {
30 listCmd := &cobra.Command{
31 Use: "nodes",
32 Aliases: []string{"node"},
33 Short: "List Hubble nodes",
34 RunE: func(cmd *cobra.Command, _ []string) error {
35 ctx, cancel := context.WithCancel(cmd.Context())
36 defer cancel()
37 hubbleConn, err := conn.NewWithFlags(ctx, vp)
38 if err != nil {
39 return err
40 }
41 defer hubbleConn.Close()
42 return runListNodes(ctx, cmd, hubbleConn)
43 },
44 }
45
46 // formatting flags
47 formattingFlags := pflag.NewFlagSet("Formatting", pflag.ContinueOnError)
48 formattingFlags.StringVarP(
49 &listOpts.output, "output", "o", "table",
50 `Specify the output format, one of:
51 json: JSON encoding
52 table: Tab-aligned columns
53 wide: Tab-aligned columns with additional information`)
54 listCmd.Flags().AddFlagSet(formattingFlags)
55
56 // advanced completion for flags
57 listCmd.RegisterFlagCompletionFunc("output", func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
58 return []string{
59 "json",
60 "table",
61 "wide",
62 }, cobra.ShellCompDirectiveDefault
63 })
64
65 template.RegisterFlagSets(listCmd, formattingFlags, config.ServerFlags)
66 return listCmd
67}
68
69func runListNodes(ctx context.Context, cmd *cobra.Command, conn *grpc.ClientConn) error {
70 req := &observerpb.GetNodesRequest{}

Callers 1

NewFunction · 0.85

Calls 6

NewWithFlagsFunction · 0.92
RegisterFlagSetsFunction · 0.92
runListNodesFunction · 0.85
ContextMethod · 0.65
CloseMethod · 0.65
FlagsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…