Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
handle array out of range error
Browse files Browse the repository at this point in the history
  • Loading branch information
yolossn committed Sep 13, 2020
1 parent 2e99f23 commit c95e751
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pkg/gui/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func (gui *Gui) onResourceClick(g *gocui.Gui, v *gocui.View) error {
func (gui *Gui) handleJobSelect(v *gocui.View) error {
// Find Selected Job
jobSelected := gui.panelStates.Resource.SelectedLine

if jobSelected < 0 || jobSelected > len(gui.data.JobData) {
return nil
}

job := gui.data.JobData[jobSelected]

infoView := gui.getInfoView()
Expand Down Expand Up @@ -89,6 +94,11 @@ func (gui *Gui) handleJobSelect(v *gocui.View) error {
func (gui *Gui) handleDeploymentSelect(v *gocui.View) error {
// Find Selected Deployment
deploymentSelected := gui.panelStates.Resource.SelectedLine

if deploymentSelected < 0 || deploymentSelected > len(gui.data.DeploymentData) {
return nil
}

deployment := gui.data.DeploymentData[deploymentSelected]

infoView := gui.getInfoView()
Expand Down Expand Up @@ -120,6 +130,11 @@ func (gui *Gui) handleDeploymentSelect(v *gocui.View) error {
func (gui *Gui) handleConfigMapSelect(v *gocui.View) error {
// Find Selected ConfigMap
configMapSelected := gui.panelStates.Resource.SelectedLine

if configMapSelected < 0 || configMapSelected > len(gui.data.ConfigMapData) {
return nil
}

configMap := gui.data.ConfigMapData[configMapSelected]

infoView := gui.getInfoView()
Expand Down Expand Up @@ -151,6 +166,11 @@ func (gui *Gui) handleConfigMapSelect(v *gocui.View) error {
func (gui *Gui) handleSecretSelect(v *gocui.View) error {
// Find Selected Secret
secretSelected := gui.panelStates.Resource.SelectedLine

if secretSelected < 0 || secretSelected > len(gui.data.SecretData) {
return nil
}

secret := gui.data.SecretData[secretSelected]

infoView := gui.getInfoView()
Expand Down Expand Up @@ -182,6 +202,11 @@ func (gui *Gui) handleSecretSelect(v *gocui.View) error {
func (gui *Gui) handleServiceSelect(v *gocui.View) error {
// Find Selected Service
serviceSelected := gui.panelStates.Resource.SelectedLine

if serviceSelected < 0 || serviceSelected > len(gui.data.ServiceData) {
return nil
}

service := gui.data.ServiceData[serviceSelected]

infoView := gui.getInfoView()
Expand Down Expand Up @@ -214,6 +239,10 @@ func (gui *Gui) handlePodSelect(v *gocui.View) error {

// Find Selected Pod
podSelected := gui.panelStates.Resource.SelectedLine
if podSelected < 0 || podSelected > len(gui.data.PodData) {
return nil
}

pod := gui.data.PodData[podSelected]

infoView := gui.getInfoView()
Expand Down

0 comments on commit c95e751

Please sign in to comment.