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 PATCH support to Vault CLI #17650

Merged
merged 3 commits into from
Oct 26, 2022
Merged

Conversation

cipherboy
Copy link
Contributor

This adds patch as a top-level command in the vault CLI, allowing access to these endpoints from our default CLI. Under the covers, we simply delegate info to a client.Logical().JSONMergePatch(...) call instead of Write(...), making this fairly simple to implement. Unlike vault kv patch though, we don't dump all of the data in an inner data: ... struct however, as non-KVv2 PATCH APIs don't require that structure.

@cipherboy
Copy link
Contributor Author

Ah, looks like I've gotta add a real PKI engine here. Hmmm... Something for tomorrow!

Copy link
Contributor

@ccapurso ccapurso left a comment

Choose a reason for hiding this comment

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

Looks good, just a couple small comments. Thanks for adding!

type PatchCommand struct {
*BaseCommand

flagForce bool
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we would need a force flag for a patch given that they should already be expecting partial data. In the scenario where the data is empty (i.e. no KV pairs were provided) then no change should occur.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't we still want a force/non-force flag, so without the -force option, no PATCH call would be issued? It seems weird to issue a PATCH call with no data in it by default, unless that behavior was specifically requested... Kinda why I felt better leaving the flag than removing it.

My 2c. though :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't feel strongly about it. That's why I approved :). It just seemed potentially less dangerous to allow an empty PATCH is all.

changelog/17650.txt Outdated Show resolved Hide resolved
@ccapurso
Copy link
Contributor

Ah, looks like I've gotta add a real PKI engine here. Hmmm... Something for tomorrow!

Ah, missed the failing tests :). I'll leave my approval though as I imagine the tests fixes won't result in much of a change.

command/write.go Outdated Show resolved Hide resolved
@cipherboy cipherboy force-pushed the cipherboy-add-patch-support-to-cli branch from 5bd9f3c to 9c9137f Compare October 26, 2022 13:08
@cipherboy
Copy link
Contributor Author

\o/ tests now pass locally and I've spun up a PKI instance to test against.

This is based off the existing write command, using the
JSONMergePatch(...) API client method rather than Write(...), allowing
us to update specific fields.

Signed-off-by: Alexander Scheel <[email protected]>
Signed-off-by: Alexander Scheel <[email protected]>
Signed-off-by: Alexander Scheel <[email protected]>
@cipherboy cipherboy force-pushed the cipherboy-add-patch-support-to-cli branch from 9c9137f to 59b8bb2 Compare October 26, 2022 18:12
@cipherboy
Copy link
Contributor Author

Thanks all! Hopefully the CI will pass now that we've picked up that new CI config...

@cipherboy cipherboy enabled auto-merge (squash) October 26, 2022 18:12
@cipherboy cipherboy merged commit b0bf1c0 into main Oct 26, 2022
@cipherboy cipherboy deleted the cipherboy-add-patch-support-to-cli branch December 1, 2022 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants