Skip to content

Vault 36295 Improve plugin mgmt ux in api and cli #30811

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

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

helenfufu
Copy link
Contributor

@helenfufu helenfufu commented Jun 2, 2025

Description

This PR improves the API and CLI UX for sha256 and command following the below guidelines:

  • API: When sha256 is provided, command is required (following the existing behavior). When sha256 is not provided, command is ignored and give a warning fmt.Sprintf("When sha256 is unspecified, a plugin artifact is expected for registration and the command parameter %q will be ignored.", command).
  • CLI: When sha256 is provided and both command and oci_image are not provided, default command to plugin name. When sha256 is not provided, make the API call and propagate up the API warning.

We additionally update the plugin registration docs (overview, API, and CLI) around sha256, command, and version to capture the two supported plugin registration mechanisms at this time: binary with -sha256 and (extracted) artifact with -version only.

Local testing: link

ENT PR: https://github.com/hashicorp/vault-enterprise/pull/8365

TODO only if you're a HashiCorp employee

  • Backport Labels: If this fix needs to be backported, use the appropriate backport/ label that matches the desired release branch. Note that in the CE repo, the latest release branch will look like backport/x.x.x, but older release branches will be backport/ent/x.x.x+ent.
    • LTS: If this fixes a critical security vulnerability or severity 1 bug, it will also need to be backported to the current LTS versions of Vault. To ensure this, use all available enterprise labels.
  • ENT Breakage: If this PR either 1) removes a public function OR 2) changes the signature
    of a public function, even if that change is in a CE file, double check that
    applying the patch for this PR to the ENT repo and running tests doesn't
    break any tests. Sometimes ENT only tests rely on public functions in CE
    files.
  • Jira: If this change has an associated Jira, it's referenced either
    in the PR description, commit message, or branch name.
  • RFC: If this change has an associated RFC, please link it in the description.
  • ENT PR: If this change has an associated ENT PR, please link it in the
    description. Also, make sure the changelog is in this PR, not in your ENT PR.

@helenfufu helenfufu requested review from thyton and benashz June 2, 2025 18:32
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Jun 2, 2025
Copy link

github-actions bot commented Jun 2, 2025

CI Results:
All Go tests succeeded! ✅

@benashz benashz changed the title Vault 36295 improve plugin mgmt ux in api and cli Improve plugin mgmt ux in api and cli Jun 4, 2025
@benashz benashz changed the title Improve plugin mgmt ux in api and cli Vault 36295 Improve plugin mgmt ux in api and cli Jun 4, 2025
@helenfufu helenfufu force-pushed the vault-36295-improve-plugin-mgmt-ux-in-api-and-cli branch from ddb46b0 to 76b9dec Compare June 4, 2025 15:18
Copy link
Contributor Author

@helenfufu helenfufu Jun 4, 2025

Choose a reason for hiding this comment

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

This PR includes the doc updates for the sha256, command, and version parameters, as well as the current state of the manual registration flow with an extracted artifact.

It does not currently include any doc updates for the download functionality. IMO it would be better to get this into main first so the current state is up-to-date, and then do a subsequent PR for download docs once our vault-enterprise feature branch is shipped.

@helenfufu helenfufu added this to the 1.20.0-rc milestone Jun 4, 2025
Copy link
Contributor

@benashz benashz left a comment

Choose a reason for hiding this comment

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

This PR is looking great! I added some suggestions/nits for your consideration.

Version: "v1.0.0",
})
if err != nil {
t.Fatal(err)
}
if len(resp.Warnings) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: any chance we could check the Warnings here using reflect.DeepEqual()?

Copy link
Contributor Author

@helenfufu helenfufu Jun 4, 2025

Choose a reason for hiding this comment

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

Having a bit of trouble with this, namely needing to differentiate when resp.Warnings is []string(nil) or []string{}, which the length check handles. Are we ok ignoring this nit in favor of prioritizing the download work?

Copy link
Contributor

Choose a reason for hiding this comment

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

In the case where we don't expect a warning, we should not assert the value. Maybe I am misunderstanding. Is the suggestion to test the non-happy path?

t.Fatal(err)
}
if len(registerResp.Warnings) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: similar comment as above about testing the equality rather than the length of Warnings. Testing both is fine however.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above #30811 (comment)

return logical.ErrorResponse("must provide at least one of command or oci_image"), nil
var resp logical.Response

if sha256 == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally these parameter constraints would be handled by the Vault server API. The vault client could just pass in everything that it got from the command line to Vault and the Vault server would do the parameter checks, returning any errors to the vault client. This is not a blocker, but something to consider for the future, especially since the Vault client may be connecting to some version of Vault that does support plugin artifacts, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack for the future, thanks for the input.

There might be a misunderstanding on my side: I thought handlePluginCatalogUpdatein logical_system.go is the API handler? Where would you suggest making the change in the future?

@helenfufu helenfufu marked this pull request as ready for review June 4, 2025 19:06
@helenfufu helenfufu requested review from a team as code owners June 4, 2025 19:06
@helenfufu helenfufu requested a review from brewgator June 4, 2025 19:06
… binary plugins, which rely on plugin.Command input; extracted artifact plugins don't rely on plugin.Command input
thyton
thyton previously approved these changes Jun 25, 2025
fairclothjm
fairclothjm previously approved these changes Jun 26, 2025
Copy link
Contributor

@fairclothjm fairclothjm left a comment

Choose a reason for hiding this comment

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

Great work!

* suggestions

* move common reqs to a partial

* fix typo

* tweak reqs

* Update website/content/partials/plugins/prepare-plugin.mdx

Co-authored-by: helenfufu <[email protected]>

* Update website/content/partials/plugins/prepare-plugin.mdx

Co-authored-by: helenfufu <[email protected]>

* Update website/content/partials/plugins/prepare-plugin.mdx

Co-authored-by: helenfufu <[email protected]>

* tweak feedback

* remove deprecation

* Update website/content/partials/plugins/common-requirements.mdx

Co-authored-by: helenfufu <[email protected]>

* save

* Update website/content/docs/plugins/rollback.mdx

Co-authored-by: helenfufu <[email protected]>

* Update website/content/docs/plugins/upgrade.mdx

Co-authored-by: helenfufu <[email protected]>

* fix formatting

---------

Co-authored-by: helenfufu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.20.x hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants