I currently have something like this in my kubeconfig
exec:
apiVersion: client.authentication.k8s.io/v1
command: PATH_DETERMINED_VIA_BINARY/token_generator
args:
- --ACCESS_TOKEN
interactiveMode: Never
provideClusterInfo: false
My question is , in the above the PATH_DETERMINED_VIA_BINARY is obtained by running a binary called tginfo
like this
sudo tginfo path token --> This will return a path (like usr/lib/000012/)
Now this is the path that will contain the binary token_generator
that is used in the command above. My question is how do I call tginfo
binary to obtain a part of the path that will be used in the command ?
How I understand the problem is that you want the output of one command to run as part of another command. In Linux you can use backticks (`) for this. e.g if you want to loop through the item in a particular location. You would do:
for i in `ls`;…
So in theory something like this will work. The sudo tginfo command is inside backticks so that should get evaluated first followed by its output combined with the rest of the string.
Also look into eval. If this doesn’t work.
exec:
apiVersion: client.authentication.k8s.io/v1
command: ["/bin/sh"]
args: ["-c", "`sudo tginfo path token`/token_generator --ACCESS_TOKEN"]
interactiveMode: Never
provideClusterInfo: false