Repository navigation
replace up command with chainable core api - #6407
Conversation
Yeah, since it can be useful to execute without needing to proxy I'm leaning towards just warning as well. Including mentioning
Same.
👍 From dagql:
Does that include input object types @vito? |
@helderco Those rules only apply to regular Objects; input objects are handled separately, with similar complexity to handling input arrays. They're not too difficult to support at that layer, so I'd be OK with keeping them; they're definitely more expressive for simple cases like this, and we already need to support them in a bunch of places (container build args, pipeline labels) where forcing an ID-able object feels overkill. I think I'd be OK with doubling-down and supporting input objects all the way into modules/SDKs if we can find a nice way, but I don't completely remember what biased against them in the first place. I suppose it's just awkward having two ways to do something that conflict at the GraphQL type layer (can't have one type be both input and output). Maybe this comes down to figuring out the right patterns? re: Also poking @shykes since I remember talking about this general idea of whether Host-effect-ful things should live on |
helderco
left a comment
There was a problem hiding this comment.
LGTM 🚀, just missing the "no proxy" message when not using up.
Doesn't this contradict the current consensus reached in #6229, of not doing "magical" things with return types? For example, don't exec a returned |
@shykes That was the first idea yes but after more thinking around the fact that we don't need to strictly enforce the rule around the return type always being scalar I also realized that there's no harm in having handling of core types in the CLI. I was trying to get at this in my subsequent comment ("Loosening restrictions on return type being a scalar"), but hadn't made a decision yet on The general principle in my mind is that we shouldn't have the CLI give users a bunch of different ways of doing the same thing. For This is as opposed to That all being said, on a second thought yeah I suppose I can see some confusion arising from the fact that We can fairly easily add another field to Let me know what you think. |
What if those two were one and the same? So it would become And taking it one step further, shouldn't In the end, these three calls would become perfectly equivalent:
Which leaves us the job of choosing one name and deprecating the other two :) What am I missing? |
Yeah you're right that's totally possible; with no other changes we would sacrifice the ability to run a service without any host tunneling but that was A) just a theoretically maybe nice feature, not that important and B) something we could probably still support too on
This in particular is just how the So I'm inclined to leave that as is for now. But either way you're totally right we can just make |
|
How about
EDIT: I'm not really convinced myself, I think I still prefer Either way, I do think we should consider deprecating the chainable |
1edf5c6 to
776c742
Compare
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
|
Updated w/ So gonna merge in the interest of reducing number of pending PRs, can open follow ups if anything else comes up! |
This is one part of our efforts to consolidate dagger CLI commands, along side #6390. It removes
dagger upin favor of using aupapi chained from the coreServicetype.For example, previously you'd do:
dagger up my-svc --port 8080:80 --port 2222:22Now you do:
dagger call my-svc up --ports 8080:80 --ports 2222:22or
dagger call my-svc up --nativeor just
dagger call my-svc up(use any available local port)This change seems to have also fixed #6303 along the way for whatever reason, at least based on testing so far 🤷♂️🎉?
This one was somewhat less obvious than the equivalent for
dagger shell, so looking for feedback on some of the high level decisions here:upAPI on ServiceName
For now I just went with a field on the Service type literally called
up. Whether the nameupis best seems like prime bikeshedding material, so have at it 😄Other possibilities that came to mind so far include:
proxylocalProxy(local-proxyin the CLI command)serveLocal(serve-localin the CLI command)Overall none of them struck me personally as clearly better enough than
upto switch right away, so leftupto get thoughts from others. If I was forced to choose, I kind of likelocal-proxy, with only downside of being more verbose thanup.Behavior + Implementation
upis implemented such that it creates and starts the host service and then waits for the context to be cancelled (i.e. the cli user ctr-c's or otherwise disconnects). The CLI thus has no special handling of this type orServicein general, it's all handled server-side.The only non-obvious part of the implementation was how to display the port mappings back to the client since the CLI can't directly anymore.
.Warn, but then what is ultimately just informational showed up as a somewhat scary lookingWARN:in the CLI's outputINFOin addition toWARN+ERROR, which makes sense generally, but I am wondering if this is a new use case that might justify its existence. Not unhappy with the approach as is in this PR though, so not a big deal afaict.Handling graphql Input types as TypeDefs
The
PortForwardtype in our core API is a graphql input type, which meant that before this PR it wasn't visible to the CLI because graphql input types were ignored when converting toTypeDef.The first commit here fixes that by adding very limited support to
TypeDeffor input types. It's explicitly doc'd as being only for compatibility w/ the core API and not for use w/ user mods and has the bare minimum fields required to get this functionality w/ the CLI working.I don't love that at all but it's low impact and the alternative was to change
PortForwardto be an id-able object, which was much higher impact and a breaking change.I went down that path anyways for a bit but realized that besides being a breaking change, it actually makes the DX, at least in the Go SDK, somewhat worse since you can't just provide e.g.
&dagger.PortForward{Frontend: 123, Backend: 234}and instead have to contend with optional args (very verbose in Go) or use something we add likedagger.PortForward().WithFrontend(123).WithBackend(234).If others think that
dagger.PortForward().WithFrontend(123).WithBackend(234)is okay enough and the backwards incompatible change is not a big deal, then I'd be happy to switch to that. In general there's appeal in the ide of our core api moving entirely away from input types and exclusively using id-able objects, but not sure if it's worth it now.