@@ -117,6 +117,9 @@ func (ui *UI) deleteConfigByIndex(index int) {
117117}
118118
119119func (ui * UI ) getConfigByIndex (index int ) (string , api.Config , * api.Context ) {
120+ if ui .list .GetItemCount () == 0 {
121+ return "" , api.Config {}, & api.Context {}
122+ }
120123 contextName , _ := ui .list .GetItemText (index )
121124 for _ , config := range ui .kubeConfigs {
122125 for name , context := range config .Contexts {
@@ -133,12 +136,14 @@ func (ui *UI) createInfoTable() *tview.Table {
133136 infoTable .SetBorder (true )
134137 infoTable .SetTitle ("Cluster" )
135138 name , config , context := ui .getConfigByIndex (ui .list .GetCurrentItem ())
136- addtoTable (infoTable , "Context" , name )
137- addtoTable (infoTable , "Cluster" , context .Cluster )
138- addtoTable (infoTable , "User" , context .AuthInfo )
139+ if name != "" {
140+ addtoTable (infoTable , "Context" , name )
141+ addtoTable (infoTable , "Cluster" , context .Cluster )
142+ addtoTable (infoTable , "User" , context .AuthInfo )
139143
140- addtoTable (infoTable , "Server" , config .Clusters [context .Cluster ].Server )
141- addtoTable (infoTable , "File" , context .LocationOfOrigin )
144+ addtoTable (infoTable , "Server" , config .Clusters [context .Cluster ].Server )
145+ addtoTable (infoTable , "File" , context .LocationOfOrigin )
146+ }
142147 return infoTable
143148}
144149
@@ -186,6 +191,9 @@ func (ui *UI) createAppMain() {
186191 ui .mainFlex .AddItem (ui .views , 0 , 2 , false )
187192 ui .list .SetCurrentItem (currentIndex )
188193 ui .redrawAppMain ()
194+ if ui .list .GetItemCount () == 0 {
195+ ui .ErrorMessage ("No (other) configs found, nothing to choose from." )
196+ }
189197}
190198
191199func (ui * UI ) redrawAppMain () {
0 commit comments