Skip to content

Commit dda7d62

Browse files
committed
update
1 parent 9924085 commit dda7d62

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
kubectl-topui
22
out/
3-
demo.tape
3+
topui.tape
44
demos/
55
.DS_Store

internal/metrics/pod.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ func (m *MetricsClient) GetPodMetrics(o *top.TopPodOptions) ([]MetricValue, erro
136136
return values, nil
137137
}
138138

139-
func (m MetricsClient) GetPod(name string) (string, error) {
140-
pod, err := m.k.CoreV1().Pods(m.ns).Get(context.Background(), name, metav1.GetOptions{})
139+
func (m MetricsClient) GetPod(name, ns string) (string, error) {
140+
pod, err := m.k.CoreV1().Pods(ns).Get(context.Background(), name, metav1.GetOptions{})
141141
if err != nil {
142142
return "", err
143143
}

internal/ui/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
108108
var output string
109109
var err error
110110
if a.resource == metrics.POD {
111-
output, err = a.client.GetPod(a.itemsPane.GetSelected())
111+
output, err = a.client.GetPod(a.itemsPane.GetSelected(), a.itemsPane.GetNamespace())
112112
} else {
113113
output, err = a.client.GetNode(a.itemsPane.GetSelected())
114114
}

internal/ui/items.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,20 @@ func (l *List) SetSize(width, height int) {
106106
}
107107

108108
func (l List) GetSelected() string {
109-
current := l.content.SelectedItem().(listItem)
110-
sections := strings.Fields(string(current))
109+
sections := l.getSections()
111110
x := 0
112111
if l.resource == metrics.POD {
113112
x = 1
114113
}
115114
return sections[x]
116115
}
116+
117+
func (l List) GetNamespace() string {
118+
sections := l.getSections()
119+
return sections[0]
120+
}
121+
122+
func (l List) getSections() []string {
123+
current := l.content.SelectedItem().(listItem)
124+
return strings.Fields(string(current))
125+
}

0 commit comments

Comments
 (0)