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

trigger: Decouple Trigger from clap #2864

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

trigger: Decouple Trigger from clap #2864

wants to merge 2 commits into from

Conversation

lann
Copy link
Collaborator

@lann lann commented Sep 25, 2024

  • Rename Trigger's associated CliArgs type to GlobalConfig
  • Move that clap::Args bound into FactorsTriggerCommand
  • Fix up related code

Also (the original PR):

  • Re-export a few things to ease trigger development

Copy link
Collaborator

@rylev rylev left a comment

Choose a reason for hiding this comment

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

In general I'm in favor of reducing the number of dependencies an implementor has to explicitly depend on especially if the implementor doesn't really have a choice.

I do feel though like we've long been on a path of exposing dependencies just when we run into a place where it would be convenient. This doesn't feel particularly disciplined, and I worry that over time we're going to regret some of these decisions.

I'm not necessarily against merging this as is, so I'll approve the PR, but I wanted to voice my concern that I'm not convinced this is the right path forward.

use spin_factors_executor::{FactorsExecutorApp, FactorsInstanceBuilder};

pub use anyhow;
pub use clap::Parser;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't love making clap even more a part of the Spin public API, but alas it may be too late...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Another option would be to rename Trigger::CliArgs to e.g. ::GlobalConfig and move the Args constraint to FactorsTriggerCommand ... T::GlobalConfig: Args (and RuntimeFactorsBuilder? 🤔)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done; take a look

@@ -4,10 +4,12 @@ pub mod loader;
use std::future::Future;

use clap::Args;
use spin_core::Linker;
use spin_factors::RuntimeFactors;
pub use spin_core::Linker;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm surprised by this. I looked at a few of the external triggers, and they don't use Linker. Is this really necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Its used in the (admittedly optional) Trigger::add_to_linker signature.

- Rename `Trigger`'s associated `CliArgs` type to `GlobalConfig`
- Move that `clap::Args` bound into `FactorsTriggerCommand`
- Fix up related code

Signed-off-by: Lann Martin <[email protected]>
@lann lann changed the title trigger: Re-export a few things to ease trigger development trigger: Decouple Trigger from clap Sep 27, 2024
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.

2 participants