Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kv.get /w recurse: true is not consistent #119

Closed
t3hk0d3 opened this issue Jan 9, 2017 · 3 comments
Closed

Kv.get /w recurse: true is not consistent #119

t3hk0d3 opened this issue Jan 9, 2017 · 3 comments
Assignees
Labels
Milestone

Comments

@t3hk0d3
Copy link

t3hk0d3 commented Jan 9, 2017

Kv.get with recurse: true is not consistent if there is only single key were returned.

I am expecting array of key/values, but if there is only single key it would return just its value.

Diplomat::Kv.put('hello/world', 'test')

Diplomat::Kv.get('hello', recurse: true)
# current:
# => 'test'
# expected
# => [{ key: 'hello/world', value: 'test'}]

Current workaround is specifying decode_values: true:

Diplomat::Kv.get('hello', recurse: true, decode_values: true)
# => {[ 'Key' => 'hello/world', 'Value' => 'test', ... }]

But there is no way to make convert_to_hash to work with single key atm.

@t3hk0d3 t3hk0d3 changed the title Kv.get recurse is not consistent Kv.get with recurse is not consistent Jan 9, 2017
@t3hk0d3 t3hk0d3 changed the title Kv.get with recurse is not consistent Kv.get /w recurse: true is not consistent Jan 9, 2017
@taharah taharah added the bug label Jan 11, 2017
@taharah taharah self-assigned this Jan 11, 2017
@taharah
Copy link
Member

taharah commented Jan 11, 2017

PR has been created to resolve this bug. Please review it if you are able to.

@ghostsquad
Copy link

along these lines, convert_to_hash straight up fails when the value is a simple string.

Diplomat::Kv.get("/foo/bar/baz", recurse: true, convert_to_hash: true)
NoMethodError: undefined method `each' for "asdfasd":String

I expected to either get a hash or a string based on the value. The workaround is not very performant, as it requires me to first try with convert_to_hash: true, and if that fails, call the method again without that parameter.

@t3hk0d3
Copy link
Author

t3hk0d3 commented Jan 14, 2017

@taharah
Actually i think it should be a different method for recursive get:

Diplomat::Kv.list('foo/bar') # same as get + recurse: true
Diplomat::Kv.tree('foo/bar') # same as get + recurse: true + convert_to_hash: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Version 3.0.0
Fix breaking issues
Development

No branches or pull requests

3 participants