Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskim06 committed Feb 23, 2023
1 parent 9924085 commit dda7d62
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kubectl-topui
out/
demo.tape
topui.tape
demos/
.DS_Store
4 changes: 2 additions & 2 deletions internal/metrics/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ func (m *MetricsClient) GetPodMetrics(o *top.TopPodOptions) ([]MetricValue, erro
return values, nil
}

func (m MetricsClient) GetPod(name string) (string, error) {
pod, err := m.k.CoreV1().Pods(m.ns).Get(context.Background(), name, metav1.GetOptions{})
func (m MetricsClient) GetPod(name, ns string) (string, error) {
pod, err := m.k.CoreV1().Pods(ns).Get(context.Background(), name, metav1.GetOptions{})
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var output string
var err error
if a.resource == metrics.POD {
output, err = a.client.GetPod(a.itemsPane.GetSelected())
output, err = a.client.GetPod(a.itemsPane.GetSelected(), a.itemsPane.GetNamespace())
} else {
output, err = a.client.GetNode(a.itemsPane.GetSelected())
}
Expand Down
13 changes: 11 additions & 2 deletions internal/ui/items.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,20 @@ func (l *List) SetSize(width, height int) {
}

func (l List) GetSelected() string {
current := l.content.SelectedItem().(listItem)
sections := strings.Fields(string(current))
sections := l.getSections()
x := 0
if l.resource == metrics.POD {
x = 1
}
return sections[x]
}

func (l List) GetNamespace() string {
sections := l.getSections()
return sections[0]
}

func (l List) getSections() []string {
current := l.content.SelectedItem().(listItem)
return strings.Fields(string(current))
}

0 comments on commit dda7d62

Please sign in to comment.