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 hooks updated #3038

Merged
merged 24 commits into from
Nov 7, 2022

Conversation

joshLong145
Copy link
Contributor

implementation of proposal #2913

Addition of hooks on plugins
Allows for pre, post and clean up operations on pre existing ignite commands.

updated with develop based on pr #3011

@joshLong145 joshLong145 changed the title migration to newb branch after updating develop feat: plugin system hooks updated Nov 1, 2022
@aljo242 aljo242 added the type:new To implement new feature. label Nov 2, 2022
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.

Thanks so much for the great work ! Here is some feedback so far.

Also please make sure to run make lint and make format!

@aljo242
Copy link
Contributor

aljo242 commented Nov 2, 2022

Looks like we also need a changelog entry (example).

@tbruyelle
Copy link
Contributor

tbruyelle commented Nov 2, 2022

@joshLong145 could you enable Allow edits from maintainers. ? I would like to add a commit that reinforce the test TestLinkPluginHooks. It's currently too weak since it only checks that PreRun or PostRun are not nil. Thanks

This is a checkbox in your PR.

@joshLong145
Copy link
Contributor Author

@joshLong145 could you enable Allow edits from maintainers. ? I would like to add a commit that reinforce the test TestLinkPluginHooks. It's currently too weak since it only checks that PreRun or PostRun are not nil. Thanks

This is a checkbox in your PR.

I think i have enabled it. if there are specifics you want to see in the tests I can add it.

@tbruyelle
Copy link
Contributor

tbruyelle commented Nov 2, 2022

@joshLong145 could you enable Allow edits from maintainers. ? I would like to add a commit that reinforce the test TestLinkPluginHooks. It's currently too weak since it only checks that PreRun or PostRun are not nil. Thanks
This is a checkbox in your PR.

I think i have enabled it. if there are specifics you want to see in the tests I can add it.

Thanks but it's not completely clear in my head, I have to draft it by coding!

@tbruyelle
Copy link
Contributor

@joshLong145 I pushed a change to reinforce TestLinkPluginHooks. The test now executes all the created commands and ensures that any hook attached to one of the commands is also executed.

For that I had to change the signature of the plugin.Interface, but that was intended since if I remember well I already told you that ExecuteHook* should take the whole Hook as a parameter and not only the name.

If you look at the cases, you may find weird scenarios when the same hook is attached multiple times to the same command. At the current stage, this works, but we can choose to disable.

I will provide a second commit to update the go.mod.plush with the latest hash.

@joshLong145
Copy link
Contributor Author

@joshLong145 I pushed a change to reinforce TestLinkPluginHooks. The test now executes all the created commands and ensures that any hook attached to one of the commands is also executed.

For that I had to change the signature of the plugin.Interface, but that was intended since if I remember well I already told you that ExecuteHook* should take the whole Hook as a parameter and not only the name.

If you look at the cases, you may find weird scenarios when the same hook is attached multiple times to the same command. At the current stage, this works, but we can choose to disable.

I will provide a second commit to update the go.mod.plush with the latest hash.

Sounds good. I have some comments to address from @aljo242 i can update the hash as the final commit once those are completed

@joshLong145 joshLong145 requested review from aljo242 and tbruyelle and removed request for tbruyelle and aljo242 November 3, 2022 19:15
@tbruyelle
Copy link
Contributor

tbruyelle commented Nov 4, 2022

added flag tests to the existing test suite in ignite/cmd/plugin and ran formatters. having some issues updating the go.mod.plush with the new commit hash @tbruyelle if you could add that it would much appreciated slightly_smiling_face

I don't think it's needed to change the commit hash since your last commits didn't change the plugin interface.

About your change, what you are asserting are the command's arguments, not the command's flags. Can you rename flags to args ?

Passing command's flags to plugin Execute* methods isn't currently supported, it's WIP.

@joshLong145
Copy link
Contributor Author

added flag tests to the existing test suite in ignite/cmd/plugin and ran formatters. having some issues updating the go.mod.plush with the new commit hash @tbruyelle if you could add that it would much appreciated slightly_smiling_face

I don't think it's needed to change the commit hash since your last commits didn't change the plugin interface.

About your change, what you are asserting are the command's arguments, not the command's flags. Can you rename flags to args ?

Passing command's flags to plugin Execute* methods isn't currently supported, it's WIP.

changed the property to args also tested hooks with passing flags to commands and they pass correctly to the command implementation and hooks.

tbruyelle
tbruyelle previously approved these changes Nov 4, 2022
Copy link
Contributor

@tbruyelle tbruyelle left a comment

Choose a reason for hiding this comment

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

Tested, works like a charm, thank you @joshLong145, well done!

Note that flags support is ready, but I would like to merge yours first and adapt mine afterward.
#3060

@joshLong145
Copy link
Contributor Author

Tested, works like a charm, thank you @joshLong145, well done!

Note that flags support is ready, but I would like to merge yours first and adapt mine afterward. #3060

Yes agreed, the implementation for passing flags can be added to hooks as well. Excited to see what is built with this

@tbruyelle
Copy link
Contributor

Yes agreed, the implementation for passing flags can be added to hooks as well. Excited to see what is built with this

Yes I'll add flags support to hooks too.

tbruyelle
tbruyelle previously approved these changes Nov 4, 2022
@aljo242 aljo242 mentioned this pull request Nov 7, 2022
15 tasks
@aljo242 aljo242 merged commit b4fc516 into ignite:develop Nov 7, 2022
Jchicode pushed a commit to Jchicode/cli that referenced this pull request Aug 9, 2023
* migration to newb branch after  updating develop

* update to changelog

* moving command prefix to const

* update to commit hash for replace

* fixes to comment structure

* reinforce TestLinkPluginHooks

* chore: use latest hash for scaffolded plugin

* pr comments

* fix to error formatting

* addition of error field in test struct

* addition of arg testing in cmd plugin tests

* registering of hook struct on init of plugin

* change of flag property to args

* fix cl

Co-authored-by: josh Long <bean@joshs-MacBook-Air.local>
Co-authored-by: Thomas Bruyelle <thomas.bruyelle@tendermint.com>
Co-authored-by: Alex Johnson <alex@shmeeload.xyz>
Co-authored-by: Thomas Bruyelle <thomas.bruyelle@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:new To implement new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants