hichtakk / nsxctl

kubectl style NSX-T and ALB commannd-line client
MIT License
3 stars 2 forks source link

If t0 is down, the show route command will panic. #35

Closed mu853 closed 2 years ago

mu853 commented 2 years ago

If the specified t0 is down, a panic occurs. Should display appropriate message, not panic.

$ nsxctl show routes T0-A 
panic: interface conversion: interface {} is nil, not []interface {}

goroutine 1 [running]:
github.com/hichtakk/nsxctl/client.(*NsxtClient).GetRoutingTable(0x7a13fd8?, {0x7ffeefbffc13?, 0x1d00f18?})
    /Users/myoichi/Desktop/nsxctl/client/gateway.go:175 +0x28d
github.com/hichtakk/nsxctl/cmd.NewCmdShowRoutingTable.func1(0xc0001bdb80?, {0xc00005fb50, 0x1, 0x1?})
    /Users/myoichi/Desktop/nsxctl/cmd/nsxt-gateway.go:108 +0xa5
github.com/spf13/cobra.(*Command).execute(0xc0001bdb80, {0xc00005fb30, 0x1, 0x1})
    /Users/myoichi/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:860 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0xc000137680)
    /Users/myoichi/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
    /Users/myoichi/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:902
main.main()
    /Users/myoichi/Desktop/nsxctl/main.go:9 +0x25
$
mu853 commented 2 years ago

This was my mistake. It panics when specifying an invalid Tier-0 name, not when Tier-0 is stopped. This can occur even when auto-completion is used because the tier-0 name and Id do not match if the tier-0 name is changed after the tier-0 is created.