-
Notifications
You must be signed in to change notification settings - Fork 377
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
Set a "default" mount_point #674
Comments
Yeah that makes plenty of sense and I imagine wouldn't be too terribly difficult to implement. 👍🏻 |
There is no ready-made solution yet, can someone tell me how the functionality of setting the default value can be implemented on the current version of the code? I tried like this
But it doesn't work |
@iMisteg This is why that won't work: https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments Namely, when the module (or submodule, in this case - the class, specifically) is imported, the method's definition is read in and held in memory. This includes whatever the value is of the method's parameters' defaults. In other words, as soon as you import @jeffwecan There are two ways to fix this. Either you can make the default mount point an instance's attribute:
and OR You can implement it on each method like so:
But it MUST be EDIT: You can, of course, hybridize the two as well:
This would provide the maximum flexibility, but is quite a bit extraneous. |
(The second ( |
Any progress on this? It's a real quality of life improvement. |
Agree, this is a very useful enhancement. |
Paying customer here - This would be great to have! |
When one is using an instance of
hvac.Client
primarily with multiple operations on a single/specific mountpoint, it can become verbose/tedious to specify this samemount_point
multiple times. (Think multiple operations of listing and updating secrets across multiple paths within the same mount, for instance.)Would it be a lot of work to have an attribute on the instance that specifies the default
mount_point
? The way I see this potentially being the most user-friendly and realistic is being able to instantiate an appropriatehvac.api.VaultApiBase
subclass (such ashvac.api.secrets_engines.kv_v2.KvV2
) with a__init__(self, mount_point = None)
. If mount_point is None, it'd use theDEFAULT_MOUNT_POINT
value in each respective subclass (with 'mount_point' in each method still being able to override this and falling back to the class' attribute instead of the file-globalDEFAULT_MOUNT_POINT
).Thoughts? Am I describing this clearly? I feel like I'm not, heh.
The text was updated successfully, but these errors were encountered: