Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LP_ENABLE_KUBE_NAMESPACE set results in errors when no context available #695

Closed
rsrchboy opened this issue Jan 30, 2022 · 1 comment
Closed
Labels
bug data source Related to generation and gathering of data

Comments

@rsrchboy
Copy link

rsrchboy commented Jan 30, 2022

Shell, OS information:

error: current-context must exist in order to minify                                                                                                                                                  
[rsrchboy:~/.vim] [⎈] master(+76/-7,2)+* 20s ± echo $ZSH_VERSION 
5.8
error: current-context must exist in order to minify
[rsrchboy:~/.vim] [⎈] master(+76/-7,2)+* 127 ± uname -a      
Linux zeus 5.14.8-arch1-1 #1 SMP PREEMPT Sun, 26 Sep 2021 19:36:15 +0000 x86_64 GNU/Linux
error: current-context must exist in order to minify                                                                                                                                                                                                                                                                                         
[rsrchboy:~/.vim] [⎈] master(+76/-7,2)+* 1 ± cat /etc/os-release 
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"
LOGO=archlinux
error: current-context must exist in order to minify                                                                                                                                                  
[rsrchboy:~/.vim] [⎈] master(+76/-7,2)+* ± 

kubectl version:

Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.3", GitCommit:"816c97ab8cff8a1c72eccca1026f7820e93e0d25", GitTreeState:"archive", BuildDate:"2022-01-27T18:26:18Z", GoVersion:"go1.17.6", Compiler:"gc", Platform:"linux/amd64"}

Liquidprompt version: 9d27a43

Steps to Reproduce

  1. Set LP_ENABLE_KUBECONTEXT=1 and LP_ENABLE_KUBE_NAMESPACE=1
  2. Don't have any k8s contexts available; e.g. all minikube environments destroyed
  3. Behold, leaked error messages from kubectl

Expected Behavior

As with other bits of liquidprompt, I'd expect the k8s portion of the prompt to simply not be present when no contexts are configured.

Current Behavior

error: current-context must exist in order to minify                                                                                                                                                  
[rsrchboy:~/.vim] [⎈] master(+76/-7,2)+* ± 

Note the error, and that the k8s section of the prompt is still present.

Possible Solution

It would be easy to mask the error message, e.g. add 2>/dev/null to the relevant command. However, this would still leave the part of the prompt present.

@rsrchboy rsrchboy added the bug label Jan 30, 2022
@Rycieos Rycieos added the data source Related to generation and gathering of data label Jan 31, 2022
@Rycieos
Copy link
Collaborator

Rycieos commented Jan 31, 2022

Can confirm, nice report.

I thought I had tested this when adding the namespace feature, but obviously not.

Easy fix by nulling stderr as suggested, and adding a return 1 if the command errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug data source Related to generation and gathering of data
Projects
None yet
Development

No branches or pull requests

2 participants