Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get raw values with consul recursively over HTTP API

Tags:

consul

Referring the below documentation of consul for HTTP API

https://www.consul.io/api/kv.html

recurse (bool: false) - Specifies if the lookup should be recursive and key treated as a prefix instead of a literal match. This is specified as part of the URL as a query parameter.

raw (bool: false) - Specifies the response is just the raw value of the key, without any encoding or metadata. This is specified as part of the URL as a query parameter.

I was expecting decoded values in the response returned for below request http://localhost:8500/v1/kv/?recurse=true&raw=true

The recurse option is working as I can see all the key/val pairs present in the response JSON but the values are still encoded (base64).

Is the raw query parameter not working or am I doing something wrong?

like image 602
Vivek Avatar asked Feb 23 '18 13:02

Vivek


1 Answers

Their document is somehow misleading. These parameters will work individually. However when you try to combine them, they don't work as what you think.

Some alternative way to address what you need.

You can do first get a list of keys by

http://localhost:8500/v1/kv/?keys

And then, looping through the key and get the value individually

http://localhost:8500/v1/kv/YourKey?raw

Otherwise, decode the value in your code.

like image 179
TJ Liu Avatar answered Oct 11 '22 23:10

TJ Liu