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

function kubectl() does not work with jsonpath #53

Open
stozinho opened this issue Oct 6, 2020 · 1 comment
Open

function kubectl() does not work with jsonpath #53

stozinho opened this issue Oct 6, 2020 · 1 comment

Comments

@stozinho
Copy link

stozinho commented Oct 6, 2020

(Firstly, credit to the people on the Kubernetes slack who helped me with this!)

So I have been trying to craft a query with jsonpath to find all pods with a certain annotation.

kubectl get pod --all-namespaces -o jsonpath='{range .items[?(@.metadata.annotations.prometheus\.io/scrape=="true")]}{.metadata.name}{"\n"}{end}'

the following line prevents exectution of the above as it appears to strips out the quotes in my command
function kubectl() { echo "+ kubectl $@">&2; command kubectl $@; }

changing the function to the following does work - adding quotes around the shell variables (although what it echoes still removes the quotes).
function kubectl() { echo "+ kubectl $@">&2; command kubectl "$@"; }

@stozinho stozinho changed the title Echo command does not work with jsonpath function kubectl() does not work with jsonpath Oct 6, 2020
@rangsan
Copy link

rangsan commented Apr 1, 2021

The original kubectl() doesn't work with auto-complete alias as well. Confirmed, adding double quote around fix the issue.

ChaosMarc added a commit to ChaosMarc/kubectl-aliases that referenced this issue Sep 28, 2022
AustralEpitech pushed a commit to AustralEpitech/kubectl-aliases that referenced this issue Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants