Skip to content
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

feat: Add plugin system #10

Open
wants to merge 26 commits into
base: dev
Choose a base branch
from
Open

Conversation

tutman96
Copy link
Contributor

@tutman96 tutman96 commented Jan 1, 2025

Based on discussion #9 implement the basics of a plugin system that can be used to extend the functionality of JetKVM.

In order to accomplish this, the task is broken down into many steps:

  • Support uploading plugin archives from the web interface
  • Extract and validate the plugin
  • Web RPC methods to enumerate installed plugins and list them in the UI dynamically
  • Plugin subprocess system that can launch and shutdown a plugin
  • Uninstalling a plugin
  • JSON RPC calls to the plugin and report back the results of getPluginStatus to the UI
  • Basic JSON configuration management (separate PR)

Stacked on #28

@tutman96
Copy link
Contributor Author

tutman96 commented Jan 1, 2025

Also this currently stacks on top of #8 since that is what I used for development

@tutman96
Copy link
Contributor Author

tutman96 commented Jan 1, 2025

First item Support uploading plugin archives from the web interface has been completed.

image
image
image

@tutman96
Copy link
Contributor Author

tutman96 commented Jan 1, 2025

Finished support for extracting and validating the manifest.json of the plugin

image
image

Comment on lines +30 to +31
// TODO: there's probably a better way of doing this without relying on the file extension
if strings.HasSuffix(filePath, ".gz") {
Copy link

Choose a reason for hiding this comment

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

Grabbing the first few bytes of the file and doing:

if bytes.HasPrefix(buf, []byte{0x1F, 0x8B, 0x08}) {

can be a nicer way to handle this.

@tutman96
Copy link
Contributor Author

tutman96 commented Jan 4, 2025

Plugins are now listed dynamically, and can be enabled and disabled.

image
image
image

@tutman96
Copy link
Contributor Author

tutman96 commented Jan 4, 2025

Subprocess support has been built out with IPC connection creation and exponential backoff auto-restart while enabled. There is also graceful shutdown support, where the process manager will send a SIGTERM, wait 30s and if not gracefully shutdown, forcefully kill the process.

image

Copy link

@joshuasing joshuasing 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 working on this - it looks super cool, and I cannot wait to receive my JetKVM and test it out :)

I wanted to comment on a few things that stood out to me whilst reading the code - please see below.
P.S. There seem to be a few files without newlines at the end, which might not be preferable on POSIX systems

@eric
Copy link

eric commented Jan 5, 2025

It might be nice to pull this jsonrpc refactor into its own pull request that gets merged separately so that it doesn't confuse what is related to the plugin change vs just general improvements to use it later.

@tutman96
Copy link
Contributor Author

tutman96 commented Jan 5, 2025

It might be nice to pull this jsonrpc refactor into its own pull request that gets merged separately so that it doesn't confuse what is related to the plugin change vs just general improvements to use it later.

#28 👍

@tutman96
Copy link
Contributor Author

tutman96 commented Jan 6, 2025

image
JSON RPC calls have been implemented, and both error messages and pending-configuration states are displaying messages in the settings dialog for the plugin

@tutman96
Copy link
Contributor Author

tutman96 commented Jan 6, 2025

Going to do the configuration after this work has been merged since I technically don't need it for Tailscale support :D not that it would be much help for other things without it. Removing the WIP status on this now as it's ready to review in its current state

@tutman96 tutman96 changed the title WIP: Add plugin system Add plugin system Jan 6, 2025
@tutman96 tutman96 marked this pull request as ready for review January 6, 2025 18:21
@kashalls
Copy link

kashalls commented Jan 6, 2025

Is it possible to read from the package and show what version of the plugin that instance is running? What happens if you install two or more of the same/different version of a plugin?

@tutman96
Copy link
Contributor Author

tutman96 commented Jan 6, 2025

Is it possible to read from the package and show what version of the plugin that instance is running? What happens if you install two or more of the same/different version of a plugin?

The system will just no-op if you try to install the same version. A different version should shut down the old one and start the new one up.... let me test that.

@tutman96
Copy link
Contributor Author

tutman96 commented Jan 6, 2025

Is it possible to read from the package and show what version of the plugin that instance is running? What happens if you install two or more of the same/different version of a plugin?

Added running version, description, and homepage to the configuration dialog
image

@tutman96 tutman96 changed the title Add plugin system feat: Add plugin system Jan 6, 2025
@Nevexo
Copy link
Contributor

Nevexo commented Jan 6, 2025

For anyone looking to try this feature out before it's merged (without building it yourself), I've pulled it into jetkvm-next and added a built binary:
https://github.com/Nevexo/jetkvm-kvm/releases/tag/next-5

@CLAassistant
Copy link

CLAassistant commented Feb 13, 2025

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants