DevOps-with-Kubernetes / examples

Apache License 2.0
25 stars 31 forks source link

examples/chapter7/get-sa-token.sh correction #5

Closed vmicrodev closed 1 year ago

vmicrodev commented 1 year ago

in order for these lines https://github.com/DevOps-with-Kubernetes/examples/blob/897f59ab7e739248fcf7fa6786b45a20383da7d4/chapter7/get-sa-token.sh#L39-L40 to work

Current lines (Error: no matches found: jsonpath={.contexts[?(@.name=="minikube")].context.cluster}):

CURR_CLUSTER=$(kubectl config view -o jsonpath={.contexts[?\(@.name==\"$CURR_CXT\"\)].context.cluster})
API_ENDPOINT=$(kubectl config view -o jsonpath={.clusters[?\(@.name==\"$CURR_CLUSTER\"\)].cluster.server})

Working lines: remove brackets escape and add quotes

CURR_CLUSTER=$(kubectl config view -o jsonpath="{.contexts[?(@.name==\"$CURR_CXT\")].context.cluster}")
API_ENDPOINT=$(kubectl config view -o jsonpath="{.clusters[?(@.name==\"$CURR_CLUSTER\")].cluster.server}")
falau commented 1 year ago

Thanks for reporting the issue, I had no idea why I wrote it like this a few years ago :P I've applied the fix now. However, the script itself is also deprecated due to the change introduced in 1.24, but it doesn't harm to keep this script around.