dagger-rs/crates/dagger-sdk/README.md

55 lines
915 B
Markdown
Raw Normal View History

# dagger-sdk
2023-01-29 11:38:13 +01:00
A dagger sdk written in rust for rust.
2023-02-17 18:00:20 +01:00
## Examples
2023-01-29 11:38:13 +01:00
2023-02-17 18:00:20 +01:00
See [examples](./examples/)
2023-01-29 11:38:13 +01:00
2023-02-17 18:00:20 +01:00
Run them like so
2023-01-29 11:38:13 +01:00
2023-02-17 18:00:20 +01:00
```bash
cargo run --example first-pipeline
```
The examples match the folder name in each directory in examples
## Install
Simply install like:
```bash
cargo add dagger-sdk
2023-02-17 18:00:20 +01:00
```
### Usage
```rust
2023-02-19 21:42:46 +01:00
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect()?;
2023-02-17 18:00:20 +01:00
let version = client
2023-02-19 18:04:10 +01:00
.container()
.from("golang:1.19")
.with_exec(vec!["go", "version"])
2023-02-19 21:42:46 +01:00
.stdout().await?;
2023-02-17 18:00:20 +01:00
println!("Hello from Dagger and {}", version.trim());
Ok(())
}
```
And run it like a normal application:
```bash
cargo run
```
2023-02-19 21:42:46 +01:00
### Disclaimer
You are free to use something else than `tokio`, I haven't tested it with
anything else, but it should work with any other runtime. We don't rely on it
specifically. That might change in the future though.