Skip to content

fix(plugin): register CLI command for legacy plugins that also declare downloaders - #32743

Open
ruslan-shaydullin wants to merge 1 commit into
helm:mainfrom
ruslan-shaydullin:fix/legacy-plugin-downloader-cli
Open

ruslan-shaydullin wants to merge 1 commit into
helm:mainfrom
ruslan-shaydullin:fix/legacy-plugin-downloader-cli

Conversation

@ruslan-shaydullin

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

A legacy plugin (no apiVersion) that has both a command and downloaders loses its command in Helm 4. fromMetadataLegacy converts it to a getter/v1 plugin, and loadCLIPlugins only loads cli/v1 plugins. helm-s3 and helm-secrets are built this way, so s3:// and secrets:// still work, but helm s3 and helm secrets don't.

$ helm plugin install https://github.com/hypnoglow/helm-s3.git --version 0.17.2 --verify=false
$ helm plugin list
NAME	VERSION	TYPE     	APIVERSION	PROVENANCE	SOURCE
s3  	0.17.2 	getter/v1	legacy    	unknown   	unknown

# v4.3.0
$ helm s3 version
Error: unknown command "s3" for "helm"
Run 'helm --help' for usage.

# this branch
$ helm s3 version
0.17.2

The plugin keeps the getter/v1 type, so helm plugin list, --type and the getter path are unchanged. The legacy conversion now also builds a CLI config from usage, description and ignoreFlags, and loadCLIPlugins registers a command from it. This is how Helm 3 behaved, and the plugin docs say legacy plugins will still be supported throughout the life of Helm 4. Similar to #31613.

refs #31500. This covers legacy plugins only, not multi-type v1 plugins.

Special notes for your reviewer:

A legacy plugin with downloaders but no command still gets no command, since there is nothing to run.

cli/v1 plugins are registered first, so nothing changes for them. If the name of a legacy plugin is already taken by a built-in or another plugin, it stays a getter and loading continues (logged at debug level). For example, helm-push before v0.10 is named push, which is a built-in. Without the skip, the existing conflict check would stop loading every plugin after it.

The new field on Metadata is unexported and read through a CLIConfig() method, because SignPlugin marshals Metadata into the .prov file.

The docs already describe this behaviour, so I don't think a docs change is needed.

Tests: a new TestLoadDir case for the existing downloader fixture, a legacy fixture in pkg/cmd/testdata/helmhome (one more row in TestLoadCLIPlugins and in the completion table), and a name conflict test with two plugin dirs. I also checked by hand with helm-s3 0.17.2 against MinIO and helm-secrets 4.6.11 with sops/age: both commands work, s3:// and secrets:// still work, and helm plugin list output is the same as before.

If applicable:

  • this PR contains user facing changes (the docs needed label should be applied if so)
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

@pull-request-size pull-request-size Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 13, 2026
@github-actions github-actions Bot added the v4.x Issues and Pull Requests related to the major version v4 label Oct 13, 2026
…e downloaders

A legacy plugin.yaml with a command and downloaders is converted to a
getter/v1 plugin, and loadCLIPlugins only loads cli/v1 plugins, so the
plugin's "helm <name>" command is missing in Helm 4. Helm 3 had both.

Keep the getter/v1 type and attach a CLI config built from usage,
description and ignoreFlags. loadCLIPlugins registers cli/v1 plugins
first, then these legacy plugins, and skips a legacy command whose
name is already taken.

Refs helm#31500

Signed-off-by: Ruslan Shaydullin <[email protected]>
@ruslan-shaydullin
ruslan-shaydullin force-pushed the fix/legacy-plugin-downloader-cli branch from 2eb3a88 to 57c4328 Compare October 14, 2026 15:26
@gjenkins8
gjenkins8 requested a balanced review from Copilot October 14, 2026 16:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The compatibility fix is narrowly scoped, preserves getter behavior, handles conflicts safely, and has adequate automated coverage.

0 open findings

What changed in this PR

Restores Helm 3-compatible CLI command registration for legacy plugins that also provide downloaders.

Changes:

  • Preserves generated CLI configuration for legacy getter plugins.
  • Loads eligible legacy plugins as CLI commands while safely handling name conflicts.
  • Adds command loading, completion, conflict, and metadata tests.
File Description
internal/​plugin/​metadata.go Generates and exposes legacy CLI configuration.
internal/​plugin/​metadata_test.go Verifies downloader-only plugins remain non-CLI.
internal/​plugin/​loader_test.go Verifies legacy mixed plugin conversion.
pkg/​cmd/​load_plugins.go Registers legacy commands with CLI-first conflict precedence.
pkg/​cmd/​plugin_test.go Tests loading, execution, completion, and conflicts.
pkg/​cmd/​testdata/​legacy-conflict/​echo/​plugin.yaml Adds conflict fixture.
pkg/​cmd/​testdata/​helmhome/​helm/​plugins/​downloader/​plugin.yaml Adds mixed legacy plugin fixture.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ruslan-shaydullin

Copy link
Copy Markdown
Contributor Author

@gjenkins8 could you take a look when you have time? It's the Helm 4 regression from #31500, where legacy plugins that declare downloaders lose their helm <name> command. CI is green after the golangci-lint bump and Copilot's review came back clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files. v4.x Issues and Pull Requests related to the major version v4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants