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

Vault kv2 #37

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Vault kv2 #37

wants to merge 5 commits into from

Conversation

alextuning
Copy link

Enable Vault key/value engine V2 support

Copy link

@logic logic left a comment

Choose a reason for hiding this comment

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

Just some quick comments; looks like this may not have been tested with default values? (I use them quite a lot here.)

@@ -92,22 +106,29 @@ def lookup_generic(key, scope)
end

return nil if secret.nil?

Hiera.debug("[hiera-vault] Read secret: #{key}")
if @config[:default_field] and (@config[:default_field_behavior] == 'ignore' or (secret.data.has_key?(@config[:default_field].to_sym) and secret.data.length == 1))
Copy link

Choose a reason for hiding this comment

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

Default fields also need to handle the kv2 case (there should be a secret.data[:data].has_key?(@config[:default_field] case in here somewhere).

if @config[:default_field_parse] == 'json'
begin
data = JSON.parse(data)
data = JSON.parse(data[:data])
Copy link

Choose a reason for hiding this comment

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

I don't think this change is correct? You may want to test this.

@@ -92,22 +106,29 @@ def lookup_generic(key, scope)
end

return nil if secret.nil?

Copy link

Choose a reason for hiding this comment

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

Instead of sprinkling if @config[:kv_version] == 2 throughout the following, couldn't you just create a variable here to represents secret.data in the kv1 case, and secret.data[:data] in the kv2 case, and work off of that from here on out? (This is already a pretty ugly collection of conditionals, seems a shame to make it worse.) ie:

sd = @config[:kv_version] == 2 ? secret.data[:data] : secret.data

and then reference sd instead of secret.data everywhere, without changing any of the existing logic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants