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

Enable -field in vault kv get/put #4426

Merged
merged 5 commits into from
Apr 23, 2018
Merged

Enable -field in vault kv get/put #4426

merged 5 commits into from
Apr 23, 2018

Conversation

jefferai
Copy link
Member

Fixes #4424

@jefferai jefferai added this to the 0.10.1 milestone Apr 23, 2018
@jefferai jefferai requested review from briankassouf and calvn April 23, 2018 14:44
command/util.go Outdated
return 1
}
case map[string]interface{}:
val = data.(map[string]interface{})[field]
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing an ok check in here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a type switch :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean wrt accessing the [field] value in the data map. If the provided key doesn't exists, val will be the zero value (not sure what that would for interface{}).

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I see what you meant, not the conversion but the field lookup. Check the follow-up commit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, that's clean.

@jefferai jefferai changed the base branch from master to kv-preflight April 23, 2018 19:19
@briankassouf briankassouf merged commit eec334c into kv-preflight Apr 23, 2018
@briankassouf briankassouf deleted the issue-4424 branch April 23, 2018 19:29
briankassouf added a commit that referenced this pull request Apr 23, 2018
* Update kv command to use a preflight check

* Make the existing ui endpoint return the allowed mounts

* Add kv subcommand tests

* Enable `-field` in `vault kv get/put` (#4426)

* Enable `-field` in `vault kv get/put`

Fixes #4424

* Unify nil value handling

* Use preflight helper

* Update vkv plugin

* Add all the mount info when authenticated

* Add fix the error message on put

* add metadata test

* No need to sort the capabilities

* Remove the kv client header

* kv patch command (#4432)

* Fix test

* Fix tests

* Use permission denied instead of entity disabled
truenorthcreative pushed a commit that referenced this pull request Apr 23, 2018
* Update kv command to use a preflight check

* Make the existing ui endpoint return the allowed mounts

* Add kv subcommand tests

* Enable `-field` in `vault kv get/put` (#4426)

* Enable `-field` in `vault kv get/put`

Fixes #4424

* Unify nil value handling

* Use preflight helper

* Update vkv plugin

* Add all the mount info when authenticated

* Add fix the error message on put

* add metadata test

* No need to sort the capabilities

* Remove the kv client header

* kv patch command (#4432)

* Fix test

* Fix tests

* Use permission denied instead of entity disabled
@queglay
Copy link

queglay commented Nov 21, 2020

I was thinking because of this ticket it wouldbe possible to replace a single field at a secret path, but when I attempt to use vault kv put with -field it doesn't seem to work in vault 1.5.5

admin:((e4c08a0...)) $ vault kv get developers/dev/config/deadline_version
====== Metadata ======
Key              Value
---              -----
created_time     2020-11-21T23:27:24.159648302Z
deletion_time    n/a
destroyed        false
version          9

======= Data =======
Key            Value
---            -----
default        10.1.9.0
description    The version of the deadline installer.
example_1      10.1.9.2
value          10.1.9.0

admin:((e4c08a0...)) $ vault kv put -field=value developers/dev/config/deadline_version 10.1.9.5
Failed to parse K=V data: invalid key/value pair "10.1.9.5": format must be key=value

admin: ((e4c08a0...)) $ vault kv put -field developers/dev/config/deadline_version value=10.1.9.4
Must supply data

admin:((e4c08a0...)) $ vault kv put -field=value developers/dev/config/deadline_version value=10.1.9.4                                                                               
Field "value" not present in secret

admin:((e4c08a0...)) $ vault kv get developers/dev/config/deadline_version
====== Metadata ======
Key              Value
---              -----
created_time     2020-11-21T23:36:38.996604909Z
deletion_time    n/a
destroyed        false
version          10

==== Data ====
Key      Value
---      -----
value    10.1.9.4

I couldn't see any documentation on being able to use kv put with field so these were all my best guesses about what operation of that might be like.

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.

4 participants