Created
June 4, 2014 22:21
-
-
Save progrium/b45a9fe697dd68c3ea0f to your computer and use it in GitHub Desktop.
Consul KV client, depends on jq
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 | |
CONSUL="localhost:8500" | |
main() { | |
case "$1" in | |
info) | |
curl -s "$CONSUL/v1/kv/$2" | jq -r .[] | |
;; | |
get) | |
curl -s "$CONSUL/v1/kv/$2" | jq -r .[].Value | base64 -d | sed 's/$/\n/' | |
;; | |
set) | |
curl -s -X PUT -d "$3" "$CONSUL/v1/kv/$2" > /dev/null | |
;; | |
del) | |
curl -s -X DELETE -d "$3" "$CONSUL/v1/kv/$2" > /dev/null | |
;; | |
ls) | |
if [[ "$2" == "" ]]; then | |
curl -s "$CONSUL/v1/kv/?keys" | jq -r .[] | |
else | |
curl -s "$CONSUL/v1/kv/$2/?keys" | jq -r .[] | sed "s|$2/||" | |
fi | |
;; | |
esac | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment