-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
consul_kv: decodes kv values from Consul to utf-8 #35894
consul_kv: decodes kv values from Consul to utf-8 #35894
Conversation
This looks like the right idea but you should use our helper functions for encoding and decoding text. When you do that, the code will look like this: from ansible.module_utils._text import to_text
[...]
try:
changed = not existing or (existing and to_text(existing['Value'], errors='surrogate_or_strict') != value)
except UnicodeError:
# Existing value was undecodable but all values we set are valid utf-8
changed = True |
@abadger thanks. Why does the |
It's named such so that the API can be changed or the package moved to a
different directory without upsetting third parties too much,. (for modules
in the repo, I'll port the modules if such a thing happens,)
The API has proved to be suitably stable for enough releases now that I'm
ready to remove the leading underscore for that. However we're also
planning to move a few modules into a new subdirectory,
ansible/module_utils/common, so I've been holding off until we're ready to
do that.
…On Tue, Mar 20, 2018, 3:18 AM Colin Nolan ***@***.***> wrote:
@abadger <https://github.com/abadger> thanks. Why does the _text module
name suggest that it's (package) private? It does not look like somewhere I
should be importing things from for general use!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#35894 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMxWtz6n3uYYyZPWF9-eUynxw0aqEv1ks5tgNd9gaJpZM4R-Hjw>
.
|
41abd67
to
41a5273
Compare
Updated to use decoding helper. Also added self to authors list to speed up acceptance of future community PRs (I'm already an author on |
* Decodes kv values from Consul to utf-8. * Switches to using module utils to perform text decoding. * Adds self to authors list to help community maintenance. (cherry picked from commit a4a2b4a)
* consul_kv: decodes kv values from Consul to utf-8 (#35894) * Decodes kv values from Consul to utf-8. * Switches to using module utils to perform text decoding. * Adds self to authors list to help community maintenance. (cherry picked from commit a4a2b4a) * Add a changelog fragment for consul_kv python3 fix
SUMMARY
Fixes #35893 by decoding values from Consul as utf-8.
ISSUE TYPE
COMPONENT NAME
consul_kv
ANSIBLE VERSION
ADDITIONAL INFORMATION
N/A