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

add content for KV get operations #246

Merged
merged 34 commits into from
Apr 29, 2022

Conversation

briantist
Copy link
Collaborator

@briantist briantist commented Apr 23, 2022

SUMMARY

Adding modules and lookups for KV get.

I started with a single vault_kv_get that would take a kv_version option to decide which KV version we're dealing with, but ultimately decided on separate modules/plugins for kv1 and kv2: both the inputs (options) and outputs (return data) are different, so trying to mix them doesn't make a lot of sense.

I have mulled over the possibility of a generic vault_kv_get in addition that could A) take a kv_version, B) read the mount point info from Vault to determine which KV version it is (extra round trip + requires permissions), or C) both (like kv_version could be 1, 2, or 'auto'). I am still not so sure this "generic" one is a good idea. I won't be implementing it in this PR, but if there's demand we'll have a public discussion about it.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

vault_kv1_get (lookup & module)
vault_kv2_get (lookup & module)

ADDITIONAL INFORMATION

@briantist briantist added the enhancement New feature or request label Apr 23, 2022
@briantist briantist added this to the v2.5.0 milestone Apr 23, 2022
@briantist briantist self-assigned this Apr 23, 2022
@github-actions
Copy link

github-actions bot commented Apr 23, 2022

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and the docs are now incorporated into main:
https://community-hashi-vault-main.surge.sh

@codecov
Copy link

codecov bot commented Apr 23, 2022

Codecov Report

Merging #246 (a2c2c7a) into main (da6dded) will increase coverage by 0.44%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #246      +/-   ##
==========================================
+ Coverage   97.49%   97.94%   +0.44%     
==========================================
  Files          56       65       +9     
  Lines        2518     3060     +542     
  Branches      241      268      +27     
==========================================
+ Hits         2455     2997     +542     
  Misses         49       49              
  Partials       14       14              
Flag Coverage Δ
env_docker-default 97.94% <100.00%> (+0.44%) ⬆️
integration 81.89% <89.41%> (+1.34%) ⬆️
sanity 39.42% <43.91%> (+0.80%) ⬆️
target_ansible-doc 100.00% <100.00%> (ø)
target_auth_approle 89.47% <ø> (ø)
target_auth_aws_iam 50.00% <ø> (ø)
target_auth_cert 86.36% <ø> (ø)
target_auth_jwt 91.30% <ø> (ø)
target_auth_ldap 89.47% <ø> (ø)
target_auth_none 100.00% <ø> (ø)
target_auth_token 71.42% <ø> (ø)
target_auth_userpass 85.71% <ø> (ø)
target_connection_options 74.76% <ø> (ø)
target_controller 79.31% <98.47%> (+3.80%) ⬆️
target_filter_vault_login_token 77.77% <ø> (ø)
target_import 39.42% <43.91%> (+0.80%) ⬆️
target_lookup_hashi_vault 81.33% <ø> (ø)
target_lookup_vault_kv1_get 91.30% <91.30%> (?)
target_lookup_vault_kv2_get 91.11% <91.11%> (?)
target_lookup_vault_login 100.00% <ø> (ø)
target_lookup_vault_read 90.00% <ø> (ø)
target_lookup_vault_token_create 82.97% <ø> (ø)
target_lookup_vault_write 59.14% <ø> (ø)
target_module_utils 95.90% <ø> (ø)
target_module_vault_kv1_get 87.23% <87.23%> (?)
target_module_vault_kv2_get 86.95% <86.95%> (?)
target_module_vault_login 93.93% <ø> (ø)
target_module_vault_pki_generate_certificate 78.26% <ø> (ø)
target_module_vault_read 92.10% <ø> (ø)
target_module_vault_token_create 90.00% <ø> (ø)
target_module_vault_write 57.53% <ø> (ø)
target_modules 76.13% <96.41%> (+5.93%) ⬆️
units 94.41% <98.52%> (+0.91%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
plugins/doc_fragments/backend_mount.py 100.00% <100.00%> (ø)
plugins/lookup/vault_kv1_get.py 100.00% <100.00%> (ø)
plugins/lookup/vault_kv2_get.py 100.00% <100.00%> (ø)
plugins/modules/vault_kv1_get.py 100.00% <100.00%> (ø)
plugins/modules/vault_kv2_get.py 100.00% <100.00%> (ø)
tests/unit/plugins/lookup/test_vault_kv1_get.py 100.00% <100.00%> (ø)
tests/unit/plugins/lookup/test_vault_kv2_get.py 100.00% <100.00%> (ø)
tests/unit/plugins/modules/test_vault_kv1_get.py 100.00% <100.00%> (ø)
tests/unit/plugins/modules/test_vault_kv2_get.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da6dded...a2c2c7a. Read the comment docs.

Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only glanced over it (and ignored the tests :) ), but it looks good to me!

@briantist
Copy link
Collaborator Author

thanks for taking a look @felixfontein !

Comment on lines +125 to +128
custom_metadata": null
deletion_time": ""
destroyed": false
version": 2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super late, but are these missing opening quotes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's more that they have closing quotes that shouldn't be there :-)

This is actually valid YAML (just checked), you get a dictionary where the keys end with ". Which is likely not what the API returns.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, that was not intentional.. thanks @lowlydba !
I'll fix it when I fix #258 , before this stuff is released.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #264 if you have a moment @lowlydba , thank you!!

@briantist briantist mentioned this pull request May 1, 2022
@briantist briantist deleted the content/vault_kv_get branch May 1, 2022 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants