"Return current Kubernetes context."
(car (process-lines kubed-kubectl-program "config" "current-context")))
+(defun kubed-read-default-namespace-non-empty (context)
+ "Prompt for a default namespace for CONTEXT, refusing empty input."
+ (let ((ns (kubed-read-namespace
+ (format "Default namespace for context `%s'" context)
+ nil nil context)))
+ (when (string-empty-p ns)
+ (user-error "You didn't specify a default namespace"))
+ ns))
+
(defun kubed-default-context-and-namespace ()
"Return default context and namespace as a cons cell (CONTEXT . NAMESPACE)."
(or kubed-default-context-and-namespace
(let ((context (kubed-current-context)))
(cons context
(or (kubed-current-namespace context)
- (kubed-read-namespace
- (format "Default namespace for context `%s'" context)
- nil nil context)))))))
+ (kubed-read-default-namespace-non-empty context)))))))
(defun kubed-default-context ()
"Return default `kubectl' context."