I'm trying to figure out the best way to create inline expansions of fragments of commands. The "long form" would be like:
kubectl get pods --show-labels
or
kubectl get po -o custom-columns=NAME:'{.metadata.name}',OWNER:'{.metadata.ownerReferences[0].name}',OWNER_KIND:'{.metadata. ownerReferences[0].kind}'
For the first, I have used this:
function sl(){
echo " --show-labels"
}
kubectl get pods `sl`
This works, but the following does not:
function kown(){
echo "custom-columns=NAME:'{.metadata.name}',OWNER:'{.metadata.ownerReferences[0].name}',OWNER_KIND:'{.metadata.ownerReferences[0].kind}'"
}
kubectl get po -o `kown`
error: unexpected path string, expected a 'name1.name2' or '.name1.name2' or '{name1.name2}' or '{.name1.name2}'
Why is the second one not working? Is there a better way to do this rather than backticks and functions? I was thinking env variables but not sure. Thx for any ideas.