cmd/kgctl: fix possible nil pointer dereference
This commit is contained in:
parent
614f2e1c5d
commit
a8467f779e
@ -36,15 +36,16 @@ func runGraph(_ *cobra.Command, _ []string) error {
|
||||
return fmt.Errorf("failed to list nodes: %v", err)
|
||||
}
|
||||
var hostname string
|
||||
if len(ns) != 0 {
|
||||
hostname = ns[0].Name
|
||||
}
|
||||
nodes := make(map[string]*mesh.Node)
|
||||
for _, n := range ns {
|
||||
if n.Ready() {
|
||||
nodes[n.Name] = n
|
||||
hostname = n.Name
|
||||
}
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return fmt.Errorf("did not find any valid Kilo nodes in the cluster")
|
||||
}
|
||||
t, err := mesh.NewTopology(nodes, opts.granularity, hostname, 0, []byte{}, opts.subnet)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create topology: %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user