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

cincinnati/plugins: add plugins catalog and configuration #88

Merged
merged 3 commits into from
May 14, 2019

Conversation

lucab
Copy link
Contributor

@lucab lucab commented Apr 16, 2019

This adds a plugins catalog in order to be able to lookup plugins in
configuration entries. It also adds config deserialization for plugins,
from TOML values.

/cc @steveej

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 16, 2019
@lucab
Copy link
Contributor Author

lucab commented Apr 16, 2019

This is extracted from #74, in order to make that PR easier to rebase and review.

@lucab
Copy link
Contributor Author

lucab commented Apr 16, 2019

There is an ongoing quay outage. Tests will need to be re-triggered once that is solved.

@lucab lucab force-pushed the ups/plugins-catalog branch from 844003f to b7633f6 Compare April 17, 2019 08:07
Copy link
Contributor

@steveej steveej left a comment

Choose a reason for hiding this comment

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

Looks like a practical and simple enough approach to the issue and I think we can move forward with it! A part of me wants to disperse the centralized list of known plugins in the match statement into the plugin files as some form of macro, however it's probably better to keep it simple for now.

lucab added 3 commits May 9, 2019 13:00
This adds a plugin catalog in order to be able to match plugins in
configuration entries. It also adds config deserialization for plugins,
from TOML values.
@lucab lucab force-pushed the ups/plugins-catalog branch from b7633f6 to 15846e1 Compare May 9, 2019 13:25
@lucab
Copy link
Contributor Author

lucab commented May 9, 2019

Replied to comments and pushed an update with fixes, PTAL.

/// Settings for a plugin.
pub trait PluginSettings: Debug + Send {
/// Build the corresponding plugin for this configuration.
fn build_plugin(&self) -> Fallible<Box<Plugin<PluginIO>>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of taking ownership of self here and drop the .clone() which is used in all the implementations? That leaves it to the caller if they want to clone or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would be nice, however I'm not sure that's possible. In particular, taking the ownership and using it results in:

error[E0161]: cannot move a value of type dyn plugins::catalog::PluginSettings:
 the size of dyn plugins::catalog::PluginSettings cannot be statically determined

And adding a Sized bound turns into:

error[E0038]: the trait `plugins::catalog::PluginSettings` cannot be made into an object
   = note: the trait cannot require that `Self : Sized`

Copy link
Contributor

Choose a reason for hiding this comment

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

It does seem to me like we're not making full use of the type system here since two of the methods which need to be implemented by every plugin aren't in any trait, so it's mere convention. However I'm failing to come up with something that seems better 🤷‍♂️

@steveej
Copy link
Contributor

steveej commented May 13, 2019

I think we can ignore my idealistic remark about the implementation details and go with this approach. It definitely does what we want and has elegant settings merging with minimal repetitiveness.

@lucab
I'll let you make the last call if you do want to revisit that remark together in a call
/hold

otherwise:
/lgtm

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 13, 2019
@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 13, 2019
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lucab, steveeJ

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@lucab
Copy link
Contributor Author

lucab commented May 14, 2019

From out-of-band discussion: let's keep it as is. It still needs to be wired into application config, further tweaks may happen while doing that.

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 14, 2019
@openshift-merge-robot openshift-merge-robot merged commit 6555783 into openshift:master May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants