headlamp icon indicating copy to clipboard operation
headlamp copied to clipboard

plugin-management: make a library?

Open illume opened this issue 1 year ago • 4 comments

The plugin-management code is used by the app and headlamp-plugin. However, the previous solution for code sharing didn't work.

So plugin-management was copied into the app/. Temporarily. It was also converted to typescript.

I suggest it is turned into a new package @headlamp-k8s/plugin-management, which can be used by headlamp-plugin and the app/. Probably it should stay in ts.

Acceptance criteria

  • [ ] PluginManager.list fails if there is no plugins folder https://github.com/headlamp-k8s/plugins/pull/35/commits/72af90761d5e329c6d6981275127a51445c928bc
  • [ ] PluginManager.list todo https://github.com/headlamp-k8s/plugins/pull/35/commits/64ad979f1ae0176c03f22cc3c32903caa44adabb
  • [ ] there is a @headlamp-k8s/plugin-management library released that can be used by app/ and headlamp-plugin
  • [ ] there is documentation on how to make changes to it in development (using npm link or npm pack or whatever)
  • [ ] there are docs on how to publish it
  • [ ] installing/removing plugins works in the app
  • [ ] tests pass (unit tests, and also headlamp-plugin e2e tests)

~~@yolossn For after the release... What do you think of this proposal?~~

illume avatar Jul 25 '24 06:07 illume

Yes, it makes sense to create a new package to avoid code duplication.

yolossn avatar Jul 25 '24 07:07 yolossn

This is definitely a good idea.

Probably a little out of the scope of this issue but we have a lot of inter-component dependencies, sometimes we copy, sometimes we use "../". I think we should take an even bigger step and use monorepo tools and separate all reusable parts into packages. This would make our life a lot easier.

Some other cases I can think of:

  • headlamp-plugin uses code from frontend, we can extract it into "@headlamp-k8s/headlamp-common" that will have common components and lib
  • app uses frontend
  • example-plugins use headlamp-plugin

sniok avatar Jul 25 '24 12:07 sniok

/remove-lifecycle rotten

Faakhir30 avatar May 31 '25 13:05 Faakhir30

@illume @sniok

What purpose would the exisiting @kinvolk/headlamp-plugin serve in case of extracting plugin-management to its own package? IMO, all of the commands that @kinvolk/headlamp-plugin provides depend only on the scripts in the plugin-management. Except the start command that is watching and building, this start command requires config, lib, types, ...

So, if we extract plugin-management, we will have a package with all commands of this headlamp-plugin except the start command.

Can try implementing the above with monorepo format would make development easier, let's do following 2 for now:

  • plugins/packages/headlamp-plugin
  • plugins/packages/plugin-management (would be light weight, since FE dependencies not required, gets done all of tasks of headlamp-plugin except watch and build)

Need confirmation if I'm heading in right direction :)

Faakhir30 avatar Jun 04 '25 13:06 Faakhir30