Skip to content

plugins: Support scoped/namespace package names in headlamp-plugin#5715

Open
PrakharJain345 wants to merge 1 commit into
kubernetes-sigs:mainfrom
PrakharJain345:fix/plugins-scoped-packages
Open

plugins: Support scoped/namespace package names in headlamp-plugin#5715
PrakharJain345 wants to merge 1 commit into
kubernetes-sigs:mainfrom
PrakharJain345:fix/plugins-scoped-packages

Conversation

@PrakharJain345
Copy link
Copy Markdown
Contributor

Summary

Support scoped/namespace npm package names (e.g., @my-org/my-plugin) in the headlamp-plugin CLI build/start lifecycles and the frontend plugin manager by mapping them to flat, safe, collision-free local directory names.

Related Issue

Fixes #5714

Changes

  • plugins/headlamp-plugin/bin/headlamp-plugin.js: Update copyToPluginsFolder to translate scoped package names by stripping the @ prefix and replacing slashes with hyphens (e.g., @my-org/my-plugin maps to my-org-my-plugin).
  • frontend/src/components/App/PluginSettings/usePluginDelete.ts: Update the fallback directory-resolving logic to use the same flat, namespace-preserving pattern.

Steps to Test

  1. Create a scoped plugin or rename an existing development plugin's package name in its package.json to @test-org/my-test-plugin.
  2. Run npm run start inside the plugin directory.
  3. Verify that the plugin assets are cleanly copied to ~/.config/Headlamp/plugins/test-org-my-test-plugin/ and load correctly in Headlamp.
  4. Verify you can successfully delete/uninstall the plugin from the plugin settings UI in Headlamp.

Local Validation Results

All code linters, formatters, and compilers pass cleanly:

  • TypeScript Compiler Check: npm run frontend:tsc (Completed successfully with code 0)
  • Linter & Code Formatter: npm run frontend:lint:fix (All files formatted and linted cleanly with code 0)
  • Frontend Test Suite: npm run frontend:test (Core tests pass cleanly)

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label May 17, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: PrakharJain345
Once this PR has been reviewed and has the lgtm label, please assign illume for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 17, 2026
@illume illume requested a review from Copilot May 17, 2026 10:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for scoped npm package names (e.g. @org/plugin) in the headlamp-plugin CLI build/start lifecycle and in the frontend plugin delete flow by mapping them to a flat, collision-free local directory name (@org/pluginorg-plugin), replacing the previous logic that dropped the scope and risked collisions.

Changes:

  • Update copyToPluginsFolder in headlamp-plugin.js to strip @ and replace / with - instead of keeping only the last segment.
  • Update the folderName fallback in usePluginDelete.ts to use the same scope-preserving transformation.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
plugins/headlamp-plugin/bin/headlamp-plugin.js Maps scoped package names to a flat directory name when copying built plugin assets.
frontend/src/components/App/PluginSettings/usePluginDelete.ts Applies the same flat-name mapping in the delete-path fallback when folderName is absent.

Comment thread frontend/src/components/App/PluginSettings/usePluginDelete.ts Outdated
Copy link
Copy Markdown
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

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

Thanks for this PR.

The open review comments from Copilot still need attention — can you have a look? Once addressed, please mark them as resolved.

@PrakharJain345 PrakharJain345 force-pushed the fix/plugins-scoped-packages branch from d57ecc7 to 155a96c Compare May 17, 2026 10:52
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 17, 2026
@PrakharJain345 PrakharJain345 requested a review from illume May 17, 2026 10:53
@illume illume requested a review from Copilot May 17, 2026 19:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated no new comments.

@PrakharJain345
Copy link
Copy Markdown
Contributor Author

Hi @illume,

I wanted to let you know that all feedback on this PR has been fully addressed!

The branch has been rebased on top of main to remove any merge commits, ensuring a clean and linear history. All automated checks, tests, and formatting checks are also passing cleanly.

This is fully ready for your final review whenever you have a moment. Thanks again for your valuable time and feedback on this!

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

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plugins: Support scoped/namespace package names in headlamp-plugin CLI

4 participants