clean up type assertions

mine
derailed 2019-02-16 22:28:31 -07:00
parent d89a641225
commit be4f3f7222
2 changed files with 11 additions and 5 deletions

View File

@ -3,9 +3,9 @@ package views
import ( import (
"strings" "strings"
"github.com/derailed/k9s/config"
"github.com/derailed/k9s/resource" "github.com/derailed/k9s/resource"
"github.com/derailed/k9s/resource/k8s" "github.com/derailed/k9s/resource/k8s"
"github.com/derailed/k9s/config"
"github.com/gdamore/tcell" "github.com/gdamore/tcell"
) )
@ -46,8 +46,9 @@ func (v *contextView) useContext(*tcell.EventKey) {
v.app.flash(flashInfo, "Switching context to", ctx) v.app.flash(flashInfo, "Switching context to", ctx)
v.refresh() v.refresh()
tv := v.GetPrimitive("ctx").(*tableView) if tv, ok := v.GetPrimitive("ctx").(*tableView); ok {
tv.table.Select(0, 0) tv.table.Select(0, 0)
}
} }
func (v *contextView) extraActions(aa keyActions) { func (v *contextView) extraActions(aa keyActions) {

View File

@ -102,7 +102,9 @@ func (v *resourceView) init(ctx context.Context, ns string) {
} }
}(ctx) }(ctx)
v.refreshActions() v.refreshActions()
v.CurrentPage().Item.(*tableView).table.Select(0, 0) if tv, ok := v.CurrentPage().Item.(*tableView); ok {
tv.table.Select(0, 0)
}
} }
func (v *resourceView) getTitle() string { func (v *resourceView) getTitle() string {
@ -247,7 +249,10 @@ func (v *resourceView) refresh() {
} }
func (v *resourceView) getTV() *tableView { func (v *resourceView) getTV() *tableView {
return v.GetPrimitive(v.list.GetName()).(*tableView) if tv, ok := v.GetPrimitive(v.list.GetName()).(*tableView); ok {
return tv
}
return nil
} }
func (v *resourceView) getSelectedItem() string { func (v *resourceView) getSelectedItem() string {