14
14
* limitations under the License.
15
15
*/
16
16
17
+ import Debug from "debug"
17
18
import type { Arguments } from "@kui-shell/core"
18
19
19
20
import type Options from "./job/options.js"
@@ -117,7 +118,9 @@ type Model = Record<string, Record<string, Record<string, PodRec>>>
117
118
// host job name
118
119
119
120
export default async function jobsController ( args : Arguments < MyOptions > ) {
120
- const ns = args . parsedOptions . A ? "-A" : args . parsedOptions . n ? `-n ${ args . parsedOptions . n } ` : ""
121
+ const debug = Debug ( "plugin-codeflare-dashboard/controller/top" )
122
+ const ns = args . parsedOptions . A ? "--all-namespaces" : args . parsedOptions . n ? `-n ${ args . parsedOptions . n } ` : ""
123
+ debug ( "ns" , ns || "using namespace from user current context" )
121
124
122
125
if ( process . env . ALT !== "false" ) {
123
126
enterAltBufferMode ( )
@@ -126,6 +129,7 @@ export default async function jobsController(args: Arguments<MyOptions>) {
126
129
// To help us parse out one "record's" worth of output from kubectl
127
130
const recordSeparator = "-----------"
128
131
132
+ debug ( "spawning watcher..." )
129
133
const { spawn } = await import ( "child_process" )
130
134
const child = spawn (
131
135
"bash" ,
@@ -135,6 +139,7 @@ export default async function jobsController(args: Arguments<MyOptions>) {
135
139
] ,
136
140
{ shell : "/bin/bash" , stdio : [ "ignore" , "pipe" , "inherit" ] }
137
141
)
142
+ debug ( "spawned watcher" )
138
143
139
144
const jobIndices : Record < string , number > = { } // lookup
140
145
const jobOcc : ( undefined | string ) [ ] = [ ] // occupancy vector
@@ -171,6 +176,7 @@ export default async function jobsController(args: Arguments<MyOptions>) {
171
176
}
172
177
173
178
const initWatcher = ( cb : OnData ) => {
179
+ debug ( "init watcher callbacks" )
174
180
const me = process . env . USER || "NOUSER"
175
181
176
182
child . on ( "error" , ( err ) => console . error ( err ) )
@@ -257,13 +263,19 @@ export default async function jobsController(args: Arguments<MyOptions>) {
257
263
} )
258
264
}
259
265
266
+ debug ( "loading UI dependencies" )
260
267
const [ { render } , { createElement } , { default : Top } ] = await Promise . all ( [
261
268
import ( "ink" ) ,
262
269
import ( "react" ) ,
263
270
import ( "../../components/Top/index.js" ) ,
264
271
] )
272
+
273
+ debug ( "rendering" )
265
274
const { waitUntilExit } = await render ( createElement ( Top , { initWatcher } ) )
275
+ debug ( "initial render done" )
276
+
266
277
await waitUntilExit ( )
278
+ debug ( "exiting" )
267
279
return true
268
280
}
269
281
0 commit comments