Skip to content

Instantly share code, notes, and snippets.

@kelapure
Last active March 9, 2019 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kelapure/1670b881b02cf3abe77891ea55d411fc to your computer and use it in GitHub Desktop.
Save kelapure/1670b881b02cf3abe77891ea55d411fc to your computer and use it in GitHub Desktop.
Script to pull out the properties of your application from the config server. Name of the app is spring-music89 and the config service instance is called csi
#!/bin/bash
cf create-service-key csi config-server-key
cf service-key csi config-server-key | tail -n 6 > config-server-key.json
# Get details form config-server-key.json file
access_token_uri=$(cat config-server-key.json | jq -r ".access_token_uri")
client_id=$(cat config-server-key.json | jq -r ".client_id")
client_secret=$(cat config-server-key.json | jq -r ".client_secret")
uri=$(cat config-server-key.json | jq -r ".uri")
# Get the token using apps client credentials
TOKEN=$(curl -k $access_token_uri -u $client_id:$client_secret -d grant_type=client_credentials 2>/dev/null | jq -r .access_token)
# OR with httpie
# TOKEN=$(http --body --form POST ${access_token_uri} grant_type=client_credentials --auth $client_id:$client_secret | jq -r .access_token)
# Get the properties of myapp, in default profile
# Repeat and edit as needed
curl -k -H "Authorization: bearer $TOKEN" $uri/spring-music89/default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment