Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 6f99581

Browse files
committed
fix(plugins/plugin-kubectl): improve kubectl top node display with open sidecar
Fixes #4737
1 parent a555cd4 commit 6f99581

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

plugins/plugin-kubectl/view-utilization/src/controller/get-node-data.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,34 @@ export async function topNode(
202202
value: strings('Allocatable Memory')
203203
})
204204

205+
// hide-with-sidecar the memory and cpu columns
206+
const cpuIdx = nodeTable.header.attributes.findIndex(_ => _.key === 'CPU(cores)')
207+
if (cpuIdx >= 0) {
208+
nodeTable.header.attributes[cpuIdx].outerCSS = `${nodeTable.header.attributes[cpuIdx].outerCSS ||
209+
''} hide-with-sidecar`
210+
}
211+
const memIdx = nodeTable.header.attributes.findIndex(_ => _.key === 'MEMORY(bytes)')
212+
if (memIdx >= 0) {
213+
nodeTable.header.attributes[memIdx].outerCSS = `${nodeTable.header.attributes[memIdx].outerCSS ||
214+
''} hide-with-sidecar`
215+
}
216+
205217
// don't hide-with-sidecar the mem% column
206-
nodeTable.header.attributes[3].outerCSS = nodeTable.header.attributes[2].outerCSS.replace(/hide-with-sidecar/, '')
218+
const memPercentIdx = nodeTable.header.attributes.findIndex(_ => _.key === 'MEMORY%')
219+
nodeTable.header.attributes[memPercentIdx].outerCSS = nodeTable.header.attributes[memPercentIdx].outerCSS.replace(
220+
/hide-with-sidecar/,
221+
''
222+
)
207223

208224
nodeTable.body.forEach(row => {
209225
row.onclick = `kubectl top pod --node ${args.REPL.encodeComponent(row.name)}`
210226
row.onclickSilence = false
211227

228+
const cpuAttr = row.attributes.find(_ => _.key === 'CPU(cores)')
229+
if (cpuAttr) {
230+
cpuAttr.outerCSS = `${cpuAttr.outerCSS || ''} hide-with-sidecar`
231+
}
232+
212233
const cpuPercentAttr = row.attributes.find(_ => _.key === 'CPU%')
213234
if (cpuPercentAttr) {
214235
cpuPercentAttr.valueDom = bar({ color: BarColor.CPU, fractionString: cpuPercentAttr.value, text: true })

0 commit comments

Comments
 (0)