Wednesday, 23 February 2022

TIL - Logging into IBM Cloud with fewer keystrokes

So, back in the day i.e. earlier today, this is how I'd log into IBM Cloud: -

ic login --apikey $(cat ~/keyfile_staging_payg.json | jq -r .apikey) -r us-south -a 

where I'm using cat and jq to parse a JSON document containing my API key: -

cat ~/keyfile_staging_payg.json | jq -r .apikey

Well, today I learned that I can do it in fewer keystrokes ...

ic login --apikey @keyfile_staging_payg.json -r us-south -a https://test.cloud.ibm.com

In other words, I'm using @ rather than a combination of cat and jq.

Now, personally, I use aliases to make life even easier e.g.

testlogin='ic login --apikey @~/keyfile_staging_payg.json -c 19f41865a1cf430c918334d89f6b09b9 -r us-south -a https://test.cloud.ibm.com'

where said aliases are defined in ~/.bash_profile or ~/.zshenv.

All of which is nice!


No comments:

Reminder - how to split strings in a shell script

There's almost certainly 73 different ways to do this, but this worked for me The problem to be solved ... I have a string containing th...