openk8s 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openk8s",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "A terminal UI for Kubernetes",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -7,6 +7,6 @@ export {
7
7
  type PortForwardOverlayProps,
8
8
  buildPortForwardEntries,
9
9
  } from "./port-forward-overlay";
10
- export { LogsDialog, type LogsDialogActions, type LogsDialogProps, logLineColor } from "./logs-dialog";
10
+ export { LogsDialog, type LogsDialogActions, type LogsDialogProps } from "./logs-dialog";
11
11
  export { ScaleDialog, type ScaleDialogProps } from "./scale-dialog";
12
12
  export { HelmRollbackOverlay, type HelmRollbackOverlayProps } from "./helm-rollback-overlay";
@@ -14,16 +14,6 @@ import {
14
14
  } from "../../theme";
15
15
  import type { LoadStatus, LogOptions } from "../../../lib/k8s/types";
16
16
 
17
- function logLineColor(line: string): string {
18
- const lower = line.toLowerCase();
19
- if (/\b(error|err|fatal|panic|critical)\b/.test(lower)) return toneStyles("danger").fg;
20
- if (/\bwarn(?:ing)?\b/.test(lower)) return toneStyles("warning").fg;
21
- if (/\binfo(?:rmation)?\b/.test(lower)) return toneStyles("info").fg;
22
- if (/\bdebug\b/.test(lower)) return TEXT_SUBTLE;
23
- if (/\btrace\b/.test(lower)) return YAML_COMMENT;
24
- return TEXT_SUBTLE;
25
- }
26
-
27
17
  export interface LogsDialogActions {
28
18
  nextMatch: () => void;
29
19
  prevMatch: () => void;
@@ -184,7 +174,7 @@ export function LogsDialog({
184
174
  const matched = line.slice(matchStart, matchStart + searchText.length);
185
175
  const after = line.slice(matchStart + searchText.length);
186
176
  return (
187
- <text key={`${index}:${line}`} fg={logLineColor(line)}>
177
+ <text key={`${index}:${line}`} fg={TEXT_SUBTLE}>
188
178
  {before}
189
179
  <span fg={warningFg} attributes={isCurrentMatch ? TextAttributes.BOLD : TextAttributes.DIM}>
190
180
  {matched}
@@ -194,7 +184,7 @@ export function LogsDialog({
194
184
  );
195
185
  }
196
186
  return (
197
- <text key={`${index}:${line}`} fg={logLineColor(line)}>
187
+ <text key={`${index}:${line}`} fg={TEXT_SUBTLE}>
198
188
  {line}
199
189
  </text>
200
190
  );
@@ -300,4 +290,4 @@ export function LogsDialog({
300
290
  );
301
291
  }
302
292
 
303
- export { logLineColor };
293
+
@@ -35,10 +35,22 @@ export function handleShellKeys(
35
35
  const target = activeResourceRef;
36
36
 
37
37
  const child = kubectl.startShell({ context, namespace, resourceRef: target, namespaced });
38
- child.on("close", () => {
38
+
39
+ let stderrBuffer = "";
40
+ child.stderr?.on("data", (chunk: Buffer) => {
41
+ stderrBuffer += chunk.toString();
42
+ });
43
+
44
+ child.on("close", (code) => {
39
45
  renderer.resume();
40
46
  dispatch({ type: "setError", error: undefined });
41
- dispatch({ type: "setStatusMessage", message: `Returned from shell in ${statusLine({ ref: target })}` });
47
+ if (code === 0) {
48
+ dispatch({ type: "setStatusMessage", message: `Returned from shell in ${statusLine({ ref: target })}` });
49
+ } else {
50
+ const msg = stderrBuffer.trim() || `Shell exited with code ${code}`;
51
+ toastError(new Error(msg));
52
+ dispatch({ type: "setStatusMessage", message: `Shell failed for ${statusLine({ ref: target })}` });
53
+ }
42
54
  setManualRefreshNonce((current) => current + 1);
43
55
  });
44
56
  child.on("error", (error) => {
@@ -183,7 +183,9 @@ export function useDataFetching(
183
183
  let cancelled = false;
184
184
 
185
185
  async function loadResources(): Promise<void> {
186
- dispatch({ type: "setResourcesStatus", status: "loading" });
186
+ if (resourcesLengthRef.current === 0) {
187
+ dispatch({ type: "setResourcesStatus", status: "loading" });
188
+ }
187
189
 
188
190
  try {
189
191
  const resources = await kubectl.listResources({
@@ -380,7 +380,7 @@ export class KubectlService {
380
380
 
381
381
  args.push("exec", "-it", target, "--", "sh", "-lc", "exec ${SHELL:-/bin/sh}");
382
382
 
383
- return startPersistentProcess({ command: "kubectl", args, stdio: "inherit" });
383
+ return startPersistentProcess({ command: "kubectl", args, stdio: ["inherit", "inherit", "pipe"] });
384
384
  }
385
385
 
386
386
  editResource(options: EditResourceOptions): ChildProcess {