headlamp-k8s / headlamp

A Kubernetes web UI that is fully-featured, user-friendly and extensible
https://headlamp.dev
Apache License 2.0
2.22k stars 156 forks source link

Headlamp as an npm package #197

Open illume opened 3 years ago

illume commented 3 years ago

Current situation

Currently it's not an package.

Impact

  1. reusing code from plugins is harder without a package
  2. being on npm website provides more visibility
  3. starting headlamp is harder for npm/npx users. npx "@kinvolk/headlamp" could be convenient (npx headlamp perhaps more so).

Implementation options

Splitting out components into a separate library is fairly time consuming. Being able to import headlamp packages in plugins before this happens would be useful.

import X from '@kinvolk/headlamp/components/common';
import Y from '@kinvolk/headlamp/lib/k8s/cluster';

This doesn't stop components being split out at a later date. After separation of components into a shared library the import paths within headlamp could continue to exist where they are now.

Related to https://github.com/kinvolk/headlamp/issues/151

joaquimrocha commented 3 years ago

Hey @illume , please see my comments below:

  1. reusing code from plugins is harder without a package

That's right, and splitting out Headlamp's components into a library is a bit complex at the moment. Besides, even though the use of Headlamp as a lib would help make things a bit more clear in the development, Headlamp is not supposed to be a library in the sense that plugins will run within it, and therefore we should treat it as an external dependency on webpack at least. So IMO if there's a way for us to refer to the headlamp codebase through a regular import, but not having the whole code as a library in NPM, it'd be the way to go. Maybe there's some webpack magic to make this happen.

If my proposal cannot work without having at least files describing the API, then we can make that library.

  1. being on npm website provides more visibility

We have https://www.npmjs.com/package/@kinvolk/headlamp-plugin . I'd say it's nice to have things in NPM but it's not crucial for the success of the project.

  1. starting headlamp is harder for npm/npx users. npx "@kinvolk/headlamp" could be convenient (npx headlamp perhaps more so).

I don't think having a binary of Headlamp to run in npx is a big advantage and will bring some complexity about shipping the server for the right platform. We already have binaries for the 3 big platforms, so if we add a way to load the plugins, it should be fine for the plugin development without adding yet another maintenance burden.