mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-07-25 19:09:22 +02:00
feat(sdk): with return result instead of unwrap
This commit is contained in:
@@ -14,7 +14,7 @@ fn main() -> eyre::Result<()> {
|
||||
let source = client
|
||||
.container(None)
|
||||
.from("node:16".into())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id());
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id()?);
|
||||
|
||||
let runner = source
|
||||
.with_workdir("/src".into())
|
||||
|
@@ -12,12 +12,12 @@ fn main() -> eyre::Result<()> {
|
||||
}),
|
||||
);
|
||||
|
||||
let node_cache = client.cache_volume("node".into()).id();
|
||||
let node_cache = client.cache_volume("node".into()).id()?;
|
||||
|
||||
let source = client
|
||||
.container(None)
|
||||
.from("node:16".into())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id()?)
|
||||
.with_mounted_cache("/src/node_modules".into(), node_cache, None);
|
||||
|
||||
let runner = source
|
||||
@@ -43,11 +43,11 @@ fn main() -> eyre::Result<()> {
|
||||
let ref_ = client
|
||||
.container(None)
|
||||
.from("nginx".into())
|
||||
.with_directory("/usr/share/nginx/html".into(), build_dir.id(), None)
|
||||
.with_directory("/usr/share/nginx/html".into(), build_dir.id()?, None)
|
||||
.publish(
|
||||
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
|
||||
None,
|
||||
);
|
||||
)?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
||||
|
@@ -1,4 +1,3 @@
|
||||
|
||||
use rand::Rng;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
@@ -12,11 +11,11 @@ fn main() -> eyre::Result<()> {
|
||||
|
||||
let ref_ = client
|
||||
.container(None)
|
||||
.build(context_dir.id(), None)
|
||||
.build(context_dir.id()?, None)
|
||||
.publish(
|
||||
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
|
||||
None,
|
||||
);
|
||||
)?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
||||
|
@@ -5,7 +5,7 @@ fn main() -> eyre::Result<()> {
|
||||
.container(None)
|
||||
.from("golang:1.19".into())
|
||||
.with_exec(vec!["go".into(), "version".into()], None)
|
||||
.stdout();
|
||||
.stdout()?;
|
||||
|
||||
println!("Hello from Dagger and {}", version.trim());
|
||||
|
||||
|
@@ -15,7 +15,7 @@ fn main() -> eyre::Result<()> {
|
||||
let source = client
|
||||
.container(None)
|
||||
.from("node:16".into())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id());
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id()?);
|
||||
|
||||
let runner = source
|
||||
.with_workdir("/src".into())
|
||||
@@ -40,11 +40,11 @@ fn main() -> eyre::Result<()> {
|
||||
let ref_ = client
|
||||
.container(None)
|
||||
.from("nginx".into())
|
||||
.with_directory("/usr/share/nginx/html".into(), build_dir.id(), None)
|
||||
.with_directory("/usr/share/nginx/html".into(), build_dir.id()?, None)
|
||||
.publish(
|
||||
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
|
||||
None,
|
||||
);
|
||||
)?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
||||
|
@@ -16,7 +16,7 @@ fn main() -> eyre::Result<()> {
|
||||
let source = client
|
||||
.container(None)
|
||||
.from("node:16".into())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id());
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id()?);
|
||||
|
||||
let runner = source
|
||||
.with_workdir("/src".into())
|
||||
@@ -44,13 +44,13 @@ fn main() -> eyre::Result<()> {
|
||||
.from("nginx".into())
|
||||
.with_directory(
|
||||
"/usr/share/nginx/html".into(),
|
||||
client.host().directory(output.into(), None).id(),
|
||||
client.host().directory(output.into(), None).id()?,
|
||||
None,
|
||||
)
|
||||
.publish(
|
||||
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
|
||||
None,
|
||||
);
|
||||
)?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
||||
|
@@ -14,7 +14,7 @@ fn main() -> eyre::Result<()> {
|
||||
let source = client
|
||||
.container(None)
|
||||
.from("node:16".into())
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id());
|
||||
.with_mounted_directory("/src".into(), host_source_dir.id()?);
|
||||
|
||||
let runner = source
|
||||
.with_workdir("/src".into())
|
||||
@@ -30,7 +30,7 @@ fn main() -> eyre::Result<()> {
|
||||
],
|
||||
None,
|
||||
)
|
||||
.stderr();
|
||||
.stderr()?;
|
||||
|
||||
println!("{}", out);
|
||||
|
||||
|
Reference in New Issue
Block a user