Closed M0NsTeRRR closed 8 months ago
@briantist replying to your message here.
We can base the new code on :
hvac.__version__
if supported
orimport pkg_resources
pkg_resources.get_distribution('hvac').version
python 3.8 >=
from importlib.metadata import version
version('hvac')
I think I prefer to use the method we use in other areas of the code where we try to use the desired method, and then fall back, so it'd be something like:
try:
client.write_data(...)
except (NotImplementedError, AttributeError):
self.warn("blah blah")
client.write(...)
See for example:
In this case it'll be slightly different because the write
method is not really deprecated, so I'm not sure if we'll actually warn or not, and if we do, I'm not yet sure what it will say.
It's also a different situation because eventually, the code will change back to preferring write
(since that's our endgame ultimately), but the code doesn't need to account for that yet.
Since our CI can't currently use multiple hvac
versions easily, we test this condition with unit tests instead, see for example:
Maybe something like this is better, I think we don't need to warn people that don't use 'path' or 'wrap_ttl' ?
try:
client.write_data(data)
except (NotImplementedError, AttributeError):
if "path" in data or "wrap_ttl" in data:
raise_from(
AnsibleError("To support 'path' and 'wrap_ttl' key in 'data' parameter you must have hvac >= 1.2"),
HashiVaultValueError
)
else:
client.write(data)
That seems reasonable, yeah!
SUMMARY
We can't set
path
key indata
, for example to configure ACME path in PKI plugin. The issue is in hvac library see https://github.com/hvac/hvac/issues/133 I've opened this issue to track it and add a fix when hvac will fix the issueISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
COLLECTION VERSION
STEPS TO REPRODUCE
EXPECTED RESULTS
Update
path
value ofpki/config/cluster
ACTUAL RESULTS