Repository navigation
feat: add support _EXPERIMENTAL_DAGGER_CLI_BIN to rust - #5534
Conversation
From the root of the rust sdk, run:
$ env _EXPERIMENTAL_DAGGER_CLI_BIN=../../bin/dagger cargo run --example first-pipeline
The sdk will use dagger binary defined in `_EXPERIMENTAL_DAGGER_CLI_BIN`
to run the pipeline. And modify the engine to try running on local cli
when session port & token doesn't set, if this configuration is not set,
it will fallback to download cli method.
Signed-off-by: Thanabodee Charoenpiriyakij <[email protected]>
Since add support for local cli, the tests failure because of the use of deleted apis, introduced in PR dagger#5512. Fixes by switch to the api that still available, such as `fs().file(..,..)` to just `file(..,..)`, `exit_code()` to `sync()`. Signed-off-by: Thanabodee Charoenpiriyakij <[email protected]>
Signed-off-by: Thanabodee Charoenpiriyakij <[email protected]>
Re-run codegen to generate up-to-date sdk to make lint happy. Signed-off-by: Thanabodee Charoenpiriyakij <[email protected]>
a639614 to
f420a9d
Compare
|
I'm a rust noob so would prefer to get @kjuulh signoff before merge |
kjuulh
left a comment
There was a problem hiding this comment.
Some small comments. Feel free to ping me if you want to discuss the changes =D
We may have to duplicate the ENGINE version so that we've got both a
- Fetched engine version
- Running engine version
This may be useful because if we're not using the fetcher, and instead the one provided by dagger run, or just a binary, then we don't control what engine we're running on.
Otherwise, we could also just add a flag set in the user agent, such that we can see that we're running under another engine. Or use an external binary.
| if let Ok((conn, child)) = self.from_local_cli(cfg).await { | ||
| return Ok((conn, Some(child))); | ||
| } |
There was a problem hiding this comment.
It is good practice to defer to Option for cases like this, if we don't care about the error at all, we'll just continue
| if let Ok((conn, child)) = self.from_local_cli(cfg).await { | |
| return Ok((conn, Some(child))); | |
| } | |
| if let Some((conn, child)) = self.from_local_cli(cfg).await? { | |
| return Ok((conn, Some(child))); | |
| } |
There was a problem hiding this comment.
If we put ? after await then it would raise with error:
Error: failed to connect to dagger engine
Caused by:
environment variable not found
Location:
crates/dagger-sdk/examples/first-pipeline/main.rs:3:18
The error above come from running cargo run --example first-pipeline. It probably because of I used await? during fetch env variable. What should I suppose to fix in this case?
There was a problem hiding this comment.
You can just return a None instead then.
We don't care about the error, so we just return an Option,
If you don't need the error at all.
It can also be done like so.
if let Some((conn, child)) = self.from_local_cli(cfg).await.ok() { //-> this will transform an Err into an Option.
I'm not sure if this related to #5315? So we could ensure that the rust SDK still compat with the current engine that running on. |
There is a bit of overlap for sure. But I think it is fine with going what we've got now, as long as just get the bump fixed, so that the generated code matches the version it is running under. Lets keep in mind that we may need the compatibility checks at some point =D All in all, to get the issues fixed, we just need to trigger bump, so that we run under the right version, and get the function fixed, so that it either return an Error, which we transform with Hopefully the direction to resolution isn't too unclear =D |
Signed-off-by: Thanabodee Charoenpiriyakij <[email protected]>
Signed-off-by: Thanabodee Charoenpiriyakij <[email protected]>
|
@kjuulh All issues are addressed. Please kindly review it again. 🙇 |
From the root of the rust sdk, run:
The sdk will use dagger binary defined in
_EXPERIMENTAL_DAGGER_CLI_BINto run the pipeline. And modify the engine to try running on local cli when session port & token doesn't set, if this configuration is not set, it will fallback to download cli method.And also fix tests that failure because of using deleted apis. And re-generate code to make lint happy.