Closed
Description
What were you searching in the docs?
I am looking at creating my own Parameters provider and followed the example that shows how to create a provider for HashiCorp Vault. I'm doing this work because I'm writing a similar piece for the TS version.
The VaultProvider.get
method has a return type of str
, however after testing the code with Vault, I think it's not correct as at the best of my knowledge you can't store plain text strings into Vault and the SDK returns at least dictionary (key-value).
Steps to reproduce
- Run Vault in dev mode using Docker
docker run -e VAULT_DEV_ROOT_TOKEN_ID=abcde --cap-add=IPC_LOCK -p 8200:8200 --name=dev-vault vault
- Open
http://0.0.0.0:8200
in your browser and create a secret under thesecret/
path (i.e.my-secret
) - The UI will allow you to create only a key-value secret and not a string (see image below) - so create one (i.e.
{ "foo": "bar" }
- Copy the two files in the docs:
custom_provider_vault.py
&working_with_own_provider_vault.py
- Update the following fields:
- L13 ->
vault_provider = VaultProvider(vault_url="http://0.0.0.0:8200/", vault_token="abcde")
- L20 ->
endpoint_comments: Any = vault_provider.get("my-secret", transform="json")
- Run the code
Comments
I find the implementation slightly confusing for two reasons:
- The
self.vault_client.secrets.kv.v2.read_secret
method already returns adict
because the secret is stored as a JSON in the first place - Before returning the secret we stringify it (
json.dumps
) so that the method returns a string and then in the usage we passtransform="json"
to transform it back to a dict, which seems counterintuitive.
Is this related to an existing documentation section?
How can we improve?
I think we should review the return type, and potentially the implementation of the VaultProvider.get
method.
Got a suggestion in mind?
No response
Acknowledgment
- I understand the final update might be different from my proposed suggestion, or refused.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Shipped