A dagger sdk written in rust
Repository has moved to: https://github.com/dagger/dagger/tree/main/sdk/rust
A dagger sdk written in rust for rust
Home Page: https://dagger.io
License: MIT License
A dagger sdk written in rust
Repository has moved to: https://github.com/dagger/dagger/tree/main/sdk/rust
Windows support need to be explicitly supported. Right now we neither test on windows, or develop on it (I don't at least). As such this issue tracks the progress of both:
Hey, love this! Thanks for supplying it.
Perhaps I am going about this wrong, but take the following example:
#![feature(async_closure)]
use dagger_sdk::{ContainerBuildOptsBuilder, HostDirectoryOpts, QueryContainerOptsBuilder};
static DOCKER_FILES: [&str; 3] = ["Dockerfile", "Dockerfile.alpine", "Dockerfile.distroless"];
static PLATFORMS: [&str; 2] = ["linux/arm64", "linux/x86_64"];
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect().await?;
let context = client.host().directory_opts(
".",
HostDirectoryOpts {
exclude: Some(vec!["target", "client/node_modules", "client/build"]),
include: None,
},
);
for file in DOCKER_FILES {
for platform in PLATFORMS {
let ref_ = client
.container_opts(
QueryContainerOptsBuilder::default()
.platform(platform)
.build()
.unwrap(),
)
.build_opts(
context.id().await?,
ContainerBuildOptsBuilder::default()
.dockerfile(file)
.build()
.unwrap(),
)
.export("./test")
.await?;
println!("published image to: {:#?}", ref_);
}
}
Ok(())
}
How do I actually put the platform in? Currently it errors with:
error[E0277]: the trait bound `Platform: From<&str>` is not satisfied
--> ci/main.rs:25:35
|
25 | .platform(platform)
| -------- ^^^^^^^^ the trait `From<&str>` is not implemented for `Platform`
| |
| required by a bound introduced by this call
|
= note: required for `&str` to implement `Into<Platform>`
note: required by a bound in `QueryContainerOptsBuilder::platform`
But I also can't put the Platform
in there as:
error[E0423]: cannot initialize a tuple struct which contains private fields
--> ci/main.rs:27:35
|
27 | .platform(Platform(platform))
| ^^^^^^^^ help: a local variable with a similar name exists: `platform`
|
note: constructor is not visible here due to private fields
--> /home/pyxxil/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dagger-sdk-0.2.16/src/gen.rs:18:21
|
18 | pub struct Platform(String);
| ^^^^^^ private field
Any help would be great! Cheers
Currently we don't test on MacOS (aarch and amd64).
I develop on this platform and run both amd64 (via. dagger) and aarch natively, as such this can be considered to be tested. However, we need it enabled for CI as well
This can be fixed by manually downloading the dagger engine. Or downgrading.
I will fix this tomorrow
genco/rust requires nightly for whitespace detection, there is a way around it, I just need to do it manually.
This is just a small issue to keep track of it, so I don't forget to move it to stable.
Currently only agent architectures are supported. The blocker here is that qemu doesn't allow file actions as such integration tests can't be run on other architectures or platforms. To solve this issue, we need to run tests in a docker container under qemu.
Right now the codegen code is heavily inspired by the upstream python dagger sdk. There is a however a much cleaner way to parse the code. Mainly relying on enums and traits to perform predicates and such.
This would involve splitting the codegen part into a lexer and so on, to first transform it into an internal representation of the graphql, which in turn is then turned to generated code using traits etc.
This however, should wait until the API is somewhat stable to not have unnecessary refactoring.
Evidence: github.comm/kjuulh/dag
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are pending. To force PRs open, click the checkbox below.
async-trait
, base64
, clap
, dirs
, docker/setup-buildx-action
, flate2
, genco
, graphql_client
, hex-literal
, itertools
, platform-info
, reqwest
, serde
, serde_json
, sha2
, tempfile
, tokio
, tracing-subscriber
)Cargo.toml
eyre 0.6.8
color-eyre 0.6.2
serde 1.0.152
serde_json 1.0.93
tokio 1.25.0
tracing 0.1.37
tracing-subscriber 0.3.16
thiserror 1.0.40
ci/Cargo.toml
clap 4.1.6
color-eyre 0.6.2
eyre 0.6.8
tokio 1.25.0
crates/dagger-bootstrap/Cargo.toml
clap 4.1.6
crates/dagger-codegen/Cargo.toml
genco 0.17.3
convert_case 0.6.0
itertools 0.10.5
pretty_assertions 1.3.0
crates/dagger-core/Cargo.toml
base64 0.21.0
dirs 4.0.0
flate2 1.0.25
graphql_client 0.12.0
hex 0.4.3
hex-literal 0.3.4
platform-info 1.0.2
reqwest 0.11.14
sha2 0.10.6
tar 0.4.38
tempfile 3.3.0
async-trait 0.1.67
crates/dagger-sdk/Cargo.toml
dagger-core ^0.2.11
futures 0.3.28
derive_builder 0.12.0
pretty_assertions 1.3.0
rand 0.8.5
genco 0.17.3
tracing-test 0.2.4
.github/workflows/ci-multiplatform.yml
actions/checkout v3
docker/setup-qemu-action v2
docker/setup-buildx-action v2.0.0
actions/checkout v3
docker/setup-qemu-action v2
docker/setup-buildx-action v2.0.0
actions/checkout v3
.github/workflows/ci.yaml
actions/checkout v3
actions/cache v3
docker/setup-qemu-action v2
docker/setup-buildx-action v2.0.0
crazy-max/ghaction-github-runtime v2
.github/workflows/lint-pr.yml
amannn/action-semantic-pull-request v5
Hey, thanks for the quick fix with #30!
I've ran into another issue while trying to expose a port (with a protocol included).
Code:
client.from("denoland/deno:debian-1.30.3")
.with_exposed_port_opts(
53,
ContainerWithExposedPortOpts {
protocol: Some(NetworkProtocol::TCP),
description: None,
},
)
.with_exposed_port_opts(
53,
ContainerWithExposedPortOpts {
protocol: Some(NetworkProtocol::UDP),
description: None,
},
)
.export("/");
Results in the following error:
GQLClient Error: Look at json field for more details
Message: Argument "protocol" has invalid value "TCP".
Expected type "NetworkProtocol", found "TCP".
Message: Argument "protocol" has invalid value "UDP".
Expected type "NetworkProtocol", found "UDP".
Also yank the dagger-rs crate
I have the following in my .cache/dagger
:
tree ~/.cache/dagger/
~/.cache/dagger/
├── dagger-0.4.2
├── dagger-0.5.0
└── oci
└── ingest
Running the examples fails on
Error: Is a directory (os error 21)
Removing the section that calls std::fs::remove_file
fixes the problem. Not sure why deleting the other files would be necessary.
The idea behind this is to support what the other sdks do with id()
.
I.e.
directory := client.Host().Directory(...)
client.From().Container().WithDirectory("/", directory)
vs
let directory = client.host().directory(...)
client.from().container().with_directory("/", directory.id().await?)
This is quite a bit more verbose, and not as efficient.
All the sdks does this differently, for dynamic languages a directory is transmuted into a directoryId on read time when a final execution is called .exit_code
etc. Or in golang, where an interface is implemented to tell the serializer that it contains an ID, and that it should be called, when an arg is tried to be serialized. Such that a directory (struct)
as an arg is serialized as id (string)
.
The benefit of this process is that the intermediary steps aren't executed eagerly. Right now .file() or .directory()
are executed when passed to another function, instead of when .exit_code()
or equivalent is called.
There are a few blockers for fixing this:
TYPE
instead of "type"
, i.e. graphql wants non string wrapped types, while json always wants strings wrapped. It isn't possible override serdes implementation here, so instead I've opted to just remove the quotes from the string manually before passing them to the requester. Again, this may be solved using a closure, or embedding extra information in the arg, or implementing an entirely custom serializer, like what is done in go.This will probably be fixed in a single change. I am probably gonna do some experiments to see what the easiest solution will be.
The specifics are this:
should be moved to this:
dagger-sdk/crates/dagger-sdk/src/querybuilder.rs
Lines 96 to 98 in 2a29a66
When dropping the connection check if there are existing pipelines not handled, if so throw an error
This is about testing all standard apis via. gen.rs in dagger-sdk.
The goal is to produce tests for each individual feature.
I am gonna work on this over the next few weeks, but is someone wants to pitch in, feel free to reach out.
Currently dagger-run is not supported as the sdk cannot rely on an existing
connection and will try to replace the existing dagger engine
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.