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: plugin system (rebased) #2877

Merged
merged 42 commits into from
Oct 31, 2022
Merged

feat: plugin system (rebased) #2877

merged 42 commits into from
Oct 31, 2022

Conversation

tbruyelle
Copy link
Contributor

A plugin is a binary that can communicate with ignite using
github.com/hashicorp/go-plugin. When ignite is executed under a chain
configuration, it checks if the config contains plugins. If yes the
plugins are fetched, compiled and ran, which will add more commands to
the existing ones.

Fetching and compilation are cached under .ignite/plugins folder.

A new command ignite plugin has been added to manage plugins and make new
ones.

To give plugins the ability to load the chain, the function
cmd.NewChainWithHomeFlags is now public.


This is a rebase of #1959, with some small additional changes:

  • updated go.mod and go.sum for scaffolded plugins
  • upgraded hashicorp/go-plugins to 1.4.4
  • git init and commit scaffolded plugins

A plugin is a binary that can communicate with ignite using
github.com/hashicorp/go-plugin. When ignite is executed under a chain
configuration, it checks if the config contains plugins. If yes the
plugins are fetched, compiled and ran, which will add more commands to
the existing ones.

Fetching and compilation are cached under .ignite/plugins folder.

A new command `ignite plugin` has been added to manage plugins and make new
ones.

To give plugins the ability to load the chain, the function
`cmd.NewChainWithHomeFlags` is now public.
use hashicorp/go-plugin 1.4.4 to skip warning message
Copy link
Contributor

@aljo242 aljo242 left a comment

Choose a reason for hiding this comment

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

Are we running go mod tidy when we "install" a new plugin?

If so, we don't need to include go.sum

ignite/services/plugin/template/main.go.plush Show resolved Hide resolved
@tbruyelle
Copy link
Contributor Author

Are we running go mod tidy when we "install" a new plugin?

If so, we don't need to include go.sum

we don't, but I'll add it and remove the go.sum 👍

aljo242
aljo242 previously approved these changes Oct 7, 2022
ignite/cmd/cmd.go Outdated Show resolved Hide resolved
ignite/cmd/plugin.go Outdated Show resolved Hide resolved
@tbruyelle
Copy link
Contributor Author

tbruyelle commented Oct 10, 2022

Are we running go mod tidy when we "install" a new plugin?
If so, we don't need to include go.sum

we don't, but I'll add it and remove the go.sum +1

@aljo242 I removed the go.sum and also all the indirect dependencies (we could probably do that also for chain go.mod.plush), and then run go mod tidy 👌
aabb88a

changelog.md Show resolved Hide resolved
aljo242
aljo242 previously approved these changes Oct 20, 2022
jeronimoalbi
jeronimoalbi previously approved these changes Oct 21, 2022
changelog.md Outdated Show resolved Hide resolved
@aljo242 aljo242 requested a review from jeronimoalbi October 31, 2022 13:23
@aljo242 aljo242 merged commit 6f20b72 into develop Oct 31, 2022
@aljo242 aljo242 deleted the feat/plugin-system-rebased branch October 31, 2022 16:24
@fadeev fadeev mentioned this pull request Nov 3, 2022
Jchicode pushed a commit to Jchicode/cli that referenced this pull request Aug 9, 2023
* feat: plugin system

A plugin is a binary that can communicate with ignite using
github.com/hashicorp/go-plugin. When ignite is executed under a chain
configuration, it checks if the config contains plugins. If yes the
plugins are fetched, compiled and ran, which will add more commands to
the existing ones.

Fetching and compilation are cached under .ignite/plugins folder.

A new command `ignite plugin` has been added to manage plugins and make new
ones.

To give plugins the ability to load the chain, the function
`cmd.NewChainWithHomeFlags` is now public.

* update plugin go.mod

use hashicorp/go-plugin 1.4.4 to skip warning message

* add plugin go.sum

* git init and commit scaffolded plugins

* update CL

* fix dependecy issue

* fix missing commit author when no default config

CI doesn't have any default git config.

* fix linter

* Update ignite/services/plugin/template/main.go.plush

Co-authored-by: Alex Johnson <[email protected]>

* remove plugin go.sum and use gocmd

* Update ignite/services/plugin/plugin.go

Co-authored-by: Jerónimo Albi <[email protected]>

* remove commented line

* fix cannot use cmd.Context() there bc it's nil

* kill plugin client at the end of execution

* fix comment

* improve error handling in LoadPlugins

* remove plugin.Name

The field has no real usage, it was here to have a shorter name than the
path but dealing with the path is actually less confusing.

* fix readme for plugins

* fix: ensure plugin instances are killed

* update main so defer funcs are honored

* use const exit codes

* go mod tidy

* fix due to plushgen removal

* add PR id to CL

* change CL version

* fix CL

Co-authored-by: Alex Johnson <[email protected]>
Co-authored-by: Jerónimo Albi <[email protected]>
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.

6 participants