fermyon / spin-trigger-command

WIP Command Trigger for Spin
Apache License 2.0
3 stars 12 forks source link

Enable selecting component to execute #5

Open fibonacci1729 opened 3 months ago

fibonacci1729 commented 3 months ago

Tracking this so it doesn't get lost.

Currently the trigger can execute only the first command component. We should define a trigger flag --id/--component-id that specifies which command component to execute.

karthik2804 commented 3 months ago

implementation detail question. I can imagine not having to specify anything if there is only one component. In cases where there are multiple, would it be required to specify the ID, or if it is not specified, we fall back to executing the first component? I think we should make it compulsory in the case of multiple components as otherwise, the behavior can be confusing if the user changes the order of the components specified.

fibonacci1729 commented 3 months ago

I agree. In the case of >1 components require the component selection flag.

itowlson commented 3 months ago

Is this the right idiom? Suppose, in my manifest, I write:

[[trigger.command]]
component = "do-the-thing"

[[trigger.command]]
component = "do-the-other-thing"

It's not very obvious what this could mean.

In any other trigger, that means all those triggers are instantiated and respond to events. The equivalent semantics would be that all command components run.

But then again, I am not sure what a meaningful use case is for multiple commands in a single application. Perhaps multiple instances of the command trigger should be a validation failure.

karthik2804 commented 3 months ago

It could potentially be useful to package multiple command into a suite (I would like to imagine something like busybox) which could be a singular artifact when published via oci, so that I do not need to download multiple images?

As far as the manifest in the example provided, I would hope the author has descriptive name 😅 .

fibonacci1729 commented 3 months ago

One usecase I can imagine is not needing to duplicate variable definitions across each application on a per command basis. So multiple commands in an application can share a singular set of variables.

radu-matei commented 3 months ago

(my comment is not a feature request, just exploring the usefulness of multiple components)

There are two main scenarios I can think of here: