Last active
December 20, 2016 16:31
-
-
Save l2fprod/c21dd100f8abdceca6fe7be033cf9abe to your computer and use it in GitHub Desktop.
Sync Bluemix OpenWhisk credentials with Bluemix Cloud Foundry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
OPENWHISK_API_HOST=openwhisk.ng.bluemix.net | |
ACCESS_TOKEN=`cat ~/.cf/config.json | jq -r .AccessToken | awk '{print $2}'` | |
REFRESH_TOKEN=`cat ~/.cf/config.json | jq -r .RefreshToken` | |
ORG_NAME=`cat ~/.cf/config.json | jq -r .OrganizationFields.Name` | |
SPACE_NAME=`cat ~/.cf/config.json | jq -r .SpaceFields.Name` | |
ALL_KEYS=`curl -XPOST -k -d "{ \"accessToken\" : \"$ACCESS_TOKEN\", \"refreshToken\" : \"$REFRESH_TOKEN\" }" \ | |
-H 'Content-Type:application/json' https://$OPENWHISK_API_HOST/bluemix/v2/authenticate` | |
KEY=`echo $ALL_KEYS | jq -r '.namespaces[] | select(.name == "'$ORG_NAME'_'$SPACE_NAME'") | .key'` | |
UUID=`echo $ALL_KEYS | jq -r '.namespaces[] | select(.name == "'$ORG_NAME'_'$SPACE_NAME'") | .uuid'` | |
wsk property set --apihost $OPENWHISK_API_HOST --auth $UUID:$KEY | |
wsk property unset --namespace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment