From db978730467b4ae351f80010a224abaf4ee75e13 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Fri, 26 Jul 2024 12:22:27 +0200 Subject: [PATCH] kubed.el: Correctly handle spaces in resource properties --- lisp/net/kubed.el | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/lisp/net/kubed.el b/lisp/net/kubed.el index 84a16225dca..3eccdf39f69 100644 --- a/lisp/net/kubed.el +++ b/lisp/net/kubed.el @@ -298,7 +298,6 @@ Other keyword arguments that go between PROPERTIES and COMMANDS are: ,@(when namespaced `((concat "--all-namespaces=" (if kubed-all-namespaces-mode "true" "false")))) - "--no-headers=true" (format "--output=custom-columns=%s" (string-join (cons "NAME:.metadata.name" @@ -320,16 +319,30 @@ Other keyword arguments that go between PROPERTIES and COMMANDS are: :sentinel (lambda (_proc status) (cond ((string= status "finished\n") - (let (new) + (let (new offsets eol) (with-current-buffer ,out-name (goto-char (point-min)) + (setq eol (pos-eol)) + (while (re-search-forward "[^ ]+" eol t) + (push (1- (match-beginning 0)) offsets)) + (setq offsets (nreverse offsets)) + (forward-char 1) (while (not (eobp)) - (let ((line (buffer-substring - (point) - (progn - (forward-line 1) - (1- (point)))))) - (push (split-string line " " t) new)))) + (let ((cols nil) + (beg (car offsets)) + (ends (cdr offsets))) + (dolist (end ends) + (push (string-trim (buffer-substring + (+ (point) beg) + (+ (point) end))) + cols) + (setq beg end)) + (push (string-trim (buffer-substring + (+ (point) beg) + (pos-eol))) + cols) + (push (nreverse cols) new)) + (forward-line 1))) (setq ,list-var new ,proc-var nil) (run-hooks ',hook-var) -- 2.39.5