Repository navigation
core: Implicitly call entrypoint + defaultArgs when needed - #5039
Conversation
7735071 to
d3d09f4
Compare
|
I'm thinking |
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
d489e29 to
8bacbc8
Compare
Signed-off-by: Helder Correia <[email protected]>
8bacbc8 to
f673079
Compare
vito
left a comment
There was a problem hiding this comment.
This looks great! Just one nitpicky suggestion for one of the tests. Approving either way.
| ep, err := srv.Endpoint(ctx) | ||
| require.NoError(t, err) | ||
|
|
||
| require.Equal(t, hn+":8000", ep) |
There was a problem hiding this comment.
This seems like it would pass before the change, too. Maybe we could assert that the hostname is == to srv.WithExec(nil).Hostname(ctx) just to be super explicit?
edit: oh, I see you do that in another test below. Maybe that assertion could be moved here?
There was a problem hiding this comment.
This seems like it would pass before the change, too.
Not really. Before it would error. And this is making sure that both are adding WithExec(nil), not just one.
Notice that this test is replicating the one just above it, just replacing WithExec with WithDefaultArgs.
Maybe that assertion could be moved here?
Yes, if that makes it clearer. I added that later on. 🙂
| return parent.WithExec(ctx, s.gw, s.baseSchema.platform, args.ContainerExecOpts) | ||
| } | ||
|
|
||
| func (s *containerSchema) withDefaultExec(ctx *router.Context, parent *core.Container) (*core.Container, error) { |
There was a problem hiding this comment.
I like this - handling it at the API layer keeps the core.Container type from having to just-in-time modify itself.
This is the kind of thing I was afraid of with Dagger having to figure out what you mean, but hopefully there aren't too many examples of this. I agree it seems sensible for it to assume the default command in these cases (Hostname and Endpoint). |
|
Yes, after learning a bit more on what actually happens I totally understand your arguments for not wanting this implicit behavior, especially after thinking about I just remember the feeling of astonishment that the default command wasn't used, so I still think it's worth it to make it more intuitive. |
Signed-off-by: Helder Correia <[email protected]>
Fixes #4833, DAG-282
Before
You had to add an unintuitive
WithExec(nil)to execute theentrypoint+defaultArgs, otherwise a “no command has been executed” error would be returned. This was confusing to some users._, err := client.Container(). Build(src). + WithExec(nil). ExitCode(ctx)db := client.Container().From("postgres"). WithExposedPort(5432). + WithExec(nil) ctr := app.WithServiceBinding("db", db)After
Using
ExitCode,Stdout,StderrandWithServiceBindingwill now implicitly add theWithExec(nil)to run default command:Signed-off-by: Helder Correia