diff --git a/crates/dagger-codegen/src/rust/functions.rs b/crates/dagger-codegen/src/rust/functions.rs index 85de681..78b91e7 100644 --- a/crates/dagger-codegen/src/rust/functions.rs +++ b/crates/dagger-codegen/src/rust/functions.rs @@ -39,18 +39,44 @@ pub fn format_function(funcs: &CommonFunctions, field: &FullTypeFields) -> Optio .pipe(|t| &t.type_ref) .pipe(|t| render_output_type(funcs, t)); - Some(quote! { - $(signature)( - $(args) - ) -> $(output_type) { - let mut query = self.selection.select($(quoted(field.name.as_ref()))); + if let Some((args, true)) = args { + let required_args = format_required_function_args(funcs, field); + Some(quote! { + $(&signature)( + $(required_args) + ) -> $(output_type.as_ref()) { + let mut query = self.selection.select($(quoted(field.name.as_ref()))); - $(render_required_args(funcs, field)) - $(render_optional_args(funcs, field)) + $(render_required_args(funcs, field)) - $(render_execution(funcs, field)) - } - }) + $(render_execution(funcs, field)) + } + + $(&signature)_opts( + $args + ) -> $(output_type) { + let mut query = self.selection.select($(quoted(field.name.as_ref()))); + + $(render_required_args(funcs, field)) + $(render_optional_args(funcs, field)) + + $(render_execution(funcs, field)) + } + }) + } else { + Some(quote! { + $(signature)( + $(if let Some((args, _)) = args => $args) + ) -> $(output_type) { + let mut query = self.selection.select($(quoted(field.name.as_ref()))); + + $(render_required_args(funcs, field)) + $(render_optional_args(funcs, field)) + + $(render_execution(funcs, field)) + } + }) + } } fn render_required_args(_funcs: &CommonFunctions, field: &FullTypeFields) -> Option { @@ -215,7 +241,10 @@ fn render_execution(funcs: &CommonFunctions, field: &FullTypeFields) -> rust::To } } -fn format_function_args(funcs: &CommonFunctions, field: &FullTypeFields) -> Option { +fn format_function_args( + funcs: &CommonFunctions, + field: &FullTypeFields, +) -> Option<(rust::Tokens, bool)> { if let Some(args) = field.args.as_ref() { let args = args .into_iter() @@ -241,14 +270,51 @@ fn format_function_args(funcs: &CommonFunctions, field: &FullTypeFields) -> Opti }; if type_field_has_optional(field) { - Some(quote! { - $(required_args) - opts: Option<$(field_options_struct_name(field))> - }) + Some(( + quote! { + $(required_args) + opts: Option<$(field_options_struct_name(field))> + }, + true, + )) } else { - Some(required_args) + Some((required_args, false)) } } else { None } } + +fn format_required_function_args( + funcs: &CommonFunctions, + field: &FullTypeFields, +) -> Option { + if let Some(args) = field.args.as_ref() { + let args = args + .into_iter() + .map(|a| { + a.as_ref().and_then(|s| { + if type_ref_is_optional(&s.input_value.type_) { + return None; + } + + let t = funcs.format_input_type(&s.input_value.type_); + let n = format_struct_name(&s.input_value.name); + + Some(quote! { + $(n): $(t), + }) + }) + }) + .flatten() + .collect::>(); + let required_args = quote! { + &self, + $(for arg in args join ($['\r']) => $arg) + }; + + Some(required_args) + } else { + None + } +} diff --git a/crates/dagger-sdk/examples/build-the-application/main.rs b/crates/dagger-sdk/examples/build-the-application/main.rs index 523c25d..f98c0e7 100644 --- a/crates/dagger-sdk/examples/build-the-application/main.rs +++ b/crates/dagger-sdk/examples/build-the-application/main.rs @@ -3,7 +3,7 @@ use dagger_sdk::HostDirectoryOpts; fn main() -> eyre::Result<()> { let client = dagger_sdk::connect()?; - let host_source_dir = client.host().directory( + let host_source_dir = client.host().directory_opts( "examples/build-the-application/app", Some(HostDirectoryOpts { exclude: Some(vec!["node_modules".into(), "ci/".into()]), @@ -12,23 +12,23 @@ fn main() -> eyre::Result<()> { ); let source = client - .container(None) + .container() .from("node:16") .with_mounted_directory("/src", host_source_dir.id()?); let runner = source .with_workdir("/src") - .with_exec(vec!["npm", "install"], None); + .with_exec(vec!["npm", "install"]); - let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"], None); + let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"]); let build_dir = test - .with_exec(vec!["npm", "run", "build"], None) + .with_exec(vec!["npm", "run", "build"]) .directory("./build"); let _ = build_dir.export("./build"); - let entries = build_dir.entries(None); + let entries = build_dir.entries(); println!("build dir contents: \n {:?}", entries); diff --git a/crates/dagger-sdk/examples/caching/main.rs b/crates/dagger-sdk/examples/caching/main.rs index 28fc73f..b7ff6ed 100644 --- a/crates/dagger-sdk/examples/caching/main.rs +++ b/crates/dagger-sdk/examples/caching/main.rs @@ -3,7 +3,7 @@ use rand::Rng; fn main() -> eyre::Result<()> { let client = dagger_sdk::connect()?; - let host_source_dir = client.host().directory( + let host_source_dir = client.host().directory_opts( "./examples/caching/app", Some( dagger_sdk::HostDirectoryOptsBuilder::default() @@ -15,31 +15,28 @@ fn main() -> eyre::Result<()> { let node_cache = client.cache_volume("node").id()?; let source = client - .container(None) + .container() .from("node:16") .with_mounted_directory("/src", host_source_dir.id()?) - .with_mounted_cache("/src/node_modules", node_cache, None); + .with_mounted_cache("/src/node_modules", node_cache); let runner = source .with_workdir("/src") - .with_exec(vec!["npm", "install"], None); + .with_exec(vec!["npm", "install"]); - let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"], None); + let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"]); let build_dir = test - .with_exec(vec!["npm", "run", "build"], None) + .with_exec(vec!["npm", "run", "build"]) .directory("./build"); let mut rng = rand::thread_rng(); let ref_ = client - .container(None) + .container() .from("nginx") - .with_directory("/usr/share/nginx/html", build_dir.id()?, None) - .publish( - format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::()), - None, - )?; + .with_directory("/usr/share/nginx/html", build_dir.id()?) + .publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::()))?; println!("published image to: {}", ref_); diff --git a/crates/dagger-sdk/examples/existing-dockerfile/main.rs b/crates/dagger-sdk/examples/existing-dockerfile/main.rs index b6cfcaa..0f8d056 100644 --- a/crates/dagger-sdk/examples/existing-dockerfile/main.rs +++ b/crates/dagger-sdk/examples/existing-dockerfile/main.rs @@ -7,15 +7,12 @@ fn main() -> eyre::Result<()> { let context_dir = client .host() - .directory("./examples/existing-dockerfile/app", None); + .directory("./examples/existing-dockerfile/app"); let ref_ = client - .container(None) - .build(context_dir.id()?, None) - .publish( - format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::()), - None, - )?; + .container() + .build(context_dir.id()?) + .publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::()))?; println!("published image to: {}", ref_); diff --git a/crates/dagger-sdk/examples/first-pipeline/main.rs b/crates/dagger-sdk/examples/first-pipeline/main.rs index 5ee00c9..72cf6d7 100644 --- a/crates/dagger-sdk/examples/first-pipeline/main.rs +++ b/crates/dagger-sdk/examples/first-pipeline/main.rs @@ -2,9 +2,9 @@ fn main() -> eyre::Result<()> { let client = dagger_sdk::connect()?; let version = client - .container(None) + .container() .from("golang:1.19") - .with_exec(vec!["go", "version".into()], None) + .with_exec(vec!["go", "version".into()]) .stdout()?; println!("Hello from Dagger and {}", version.trim()); diff --git a/crates/dagger-sdk/examples/multi-stage-build/main.rs b/crates/dagger-sdk/examples/multi-stage-build/main.rs index 3c3c0f6..6b624b4 100644 --- a/crates/dagger-sdk/examples/multi-stage-build/main.rs +++ b/crates/dagger-sdk/examples/multi-stage-build/main.rs @@ -4,7 +4,7 @@ use rand::Rng; fn main() -> eyre::Result<()> { let client = dagger_sdk::connect()?; - let host_source_dir = client.host().directory( + let host_source_dir = client.host().directory_opts( "examples/publish-the-application/app", Some(HostDirectoryOpts { exclude: Some(vec!["node_modules", "ci/"]), @@ -13,30 +13,27 @@ fn main() -> eyre::Result<()> { ); let source = client - .container(None) + .container() .from("node:16") .with_mounted_directory("/src", host_source_dir.id()?); let runner = source .with_workdir("/src") - .with_exec(vec!["npm", "install"], None); + .with_exec(vec!["npm", "install"]); - let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"], None); + let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"]); let build_dir = test - .with_exec(vec!["npm", "run", "build"], None) + .with_exec(vec!["npm", "run", "build"]) .directory("./build"); let mut rng = rand::thread_rng(); let ref_ = client - .container(None) + .container() .from("nginx") - .with_directory("/usr/share/nginx/html", build_dir.id()?, None) - .publish( - format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::()), - None, - )?; + .with_directory("/usr/share/nginx/html", build_dir.id()?) + .publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::()))?; println!("published image to: {}", ref_); diff --git a/crates/dagger-sdk/examples/publish-the-application/main.rs b/crates/dagger-sdk/examples/publish-the-application/main.rs index 1b76100..8b1c06c 100644 --- a/crates/dagger-sdk/examples/publish-the-application/main.rs +++ b/crates/dagger-sdk/examples/publish-the-application/main.rs @@ -5,7 +5,7 @@ fn main() -> eyre::Result<()> { let client = dagger_sdk::connect()?; let output = "examples/publish-the-application/app/build"; - let host_source_dir = client.host().directory( + let host_source_dir = client.host().directory_opts( "examples/publish-the-application/app", Some(HostDirectoryOpts { exclude: Some(vec!["node_modules", "ci/"]), @@ -14,35 +14,31 @@ fn main() -> eyre::Result<()> { ); let source = client - .container(None) + .container() .from("node:16") .with_mounted_directory("/src", host_source_dir.id()?); let runner = source .with_workdir("/src") - .with_exec(vec!["npm", "install"], None); + .with_exec(vec!["npm", "install"]); - let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"], None); + let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"]); let _ = test - .with_exec(vec!["npm", "run", "build"], None) + .with_exec(vec!["npm", "run", "build"]) .directory("./build") .export(output); let mut rng = rand::thread_rng(); let ref_ = client - .container(None) + .container() .from("nginx") .with_directory( "/usr/share/nginx/html", - client.host().directory(output, None).id()?, - None, + client.host().directory(output).id()?, ) - .publish( - format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::()), - None, - )?; + .publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::()))?; println!("published image to: {}", ref_); diff --git a/crates/dagger-sdk/examples/test-the-application/main.rs b/crates/dagger-sdk/examples/test-the-application/main.rs index fe3328c..df76e42 100644 --- a/crates/dagger-sdk/examples/test-the-application/main.rs +++ b/crates/dagger-sdk/examples/test-the-application/main.rs @@ -3,7 +3,7 @@ use dagger_sdk::HostDirectoryOpts; fn main() -> eyre::Result<()> { let client = dagger_sdk::connect()?; - let host_source_dir = client.host().directory( + let host_source_dir = client.host().directory_opts( "examples/test-the-application/app", Some(HostDirectoryOpts { exclude: Some(vec!["node_modules", "ci/"]), @@ -12,16 +12,16 @@ fn main() -> eyre::Result<()> { ); let source = client - .container(None) + .container() .from("node:16") .with_mounted_directory("/src", host_source_dir.id()?); let runner = source .with_workdir("/src") - .with_exec(vec!["npm", "install"], None); + .with_exec(vec!["npm", "install"]); let out = runner - .with_exec(vec!["npm", "test", "--", "--watchAll=false"], None) + .with_exec(vec!["npm", "test", "--", "--watchAll=false"]) .stderr()?; println!("{}", out); diff --git a/crates/dagger-sdk/src/gen.rs b/crates/dagger-sdk/src/gen.rs index f4b8031..588bf93 100644 --- a/crates/dagger-sdk/src/gen.rs +++ b/crates/dagger-sdk/src/gen.rs @@ -22,8 +22,8 @@ pub struct SecretId(String); pub struct SocketId(String); #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] pub struct BuildArg { - pub name: String, pub value: String, + pub name: String, } pub struct CacheVolume { pub proc: Arc, @@ -125,7 +125,19 @@ pub struct ContainerWithNewFileOpts<'a> { } impl Container { - pub fn build(&self, context: DirectoryId, opts: Option) -> Container { + pub fn build(&self, context: DirectoryId) -> Container { + let mut query = self.selection.select("build"); + + query = query.arg("context", context); + + return Container { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn build_opts(&self, context: DirectoryId, opts: Option) -> Container { let mut query = self.selection.select("build"); query = query.arg("context", context); @@ -184,7 +196,17 @@ impl Container { conn: self.conn.clone(), }]; } - pub fn exec(&self, opts: Option) -> Container { + pub fn exec(&self) -> Container { + let mut query = self.selection.select("exec"); + + return Container { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn exec_opts(&self, opts: Option) -> Container { let mut query = self.selection.select("exec"); if let Some(opts) = opts { @@ -219,7 +241,15 @@ impl Container { query.execute(&graphql_client(&self.conn)) } - pub fn export( + pub fn export(&self, path: impl Into) -> eyre::Result { + let mut query = self.selection.select("export"); + + query = query.arg("path", path.into()); + + query.execute(&graphql_client(&self.conn)) + } + + pub fn export_opts( &self, path: impl Into, opts: Option, @@ -292,7 +322,19 @@ impl Container { query.execute(&graphql_client(&self.conn)) } - pub fn pipeline( + pub fn pipeline(&self, name: impl Into) -> Container { + let mut query = self.selection.select("pipeline"); + + query = query.arg("name", name.into()); + + return Container { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn pipeline_opts( &self, name: impl Into, opts: Option, @@ -317,7 +359,15 @@ impl Container { query.execute(&graphql_client(&self.conn)) } - pub fn publish( + pub fn publish(&self, address: impl Into) -> eyre::Result { + let mut query = self.selection.select("publish"); + + query = query.arg("address", address.into()); + + query.execute(&graphql_client(&self.conn)) + } + + pub fn publish_opts( &self, address: impl Into, opts: Option, @@ -357,7 +407,17 @@ impl Container { query.execute(&graphql_client(&self.conn)) } - pub fn with_default_args(&self, opts: Option) -> Container { + pub fn with_default_args(&self) -> Container { + let mut query = self.selection.select("withDefaultArgs"); + + return Container { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn with_default_args_opts(&self, opts: Option) -> Container { let mut query = self.selection.select("withDefaultArgs"); if let Some(opts) = opts { @@ -372,7 +432,20 @@ impl Container { conn: self.conn.clone(), }; } - pub fn with_directory( + pub fn with_directory(&self, path: impl Into, directory: DirectoryId) -> Container { + let mut query = self.selection.select("withDirectory"); + + query = query.arg("path", path.into()); + query = query.arg("directory", directory); + + return Container { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn with_directory_opts( &self, path: impl Into, directory: DirectoryId, @@ -427,7 +500,22 @@ impl Container { conn: self.conn.clone(), }; } - pub fn with_exec( + pub fn with_exec(&self, args: Vec>) -> Container { + let mut query = self.selection.select("withExec"); + + query = query.arg( + "args", + args.into_iter().map(|i| i.into()).collect::>(), + ); + + return Container { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn with_exec_opts( &self, args: Vec>, opts: Option, @@ -473,7 +561,20 @@ impl Container { conn: self.conn.clone(), }; } - pub fn with_file( + pub fn with_file(&self, path: impl Into, source: FileId) -> Container { + let mut query = self.selection.select("withFile"); + + query = query.arg("path", path.into()); + query = query.arg("source", source); + + return Container { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn with_file_opts( &self, path: impl Into, source: FileId, @@ -507,7 +608,20 @@ impl Container { conn: self.conn.clone(), }; } - pub fn with_mounted_cache( + pub fn with_mounted_cache(&self, path: impl Into, cache: CacheId) -> Container { + let mut query = self.selection.select("withMountedCache"); + + query = query.arg("path", path.into()); + query = query.arg("cache", cache); + + return Container { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn with_mounted_cache_opts( &self, path: impl Into, cache: CacheId, @@ -583,7 +697,19 @@ impl Container { conn: self.conn.clone(), }; } - pub fn with_new_file( + pub fn with_new_file(&self, path: impl Into) -> Container { + let mut query = self.selection.select("withNewFile"); + + query = query.arg("path", path.into()); + + return Container { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn with_new_file_opts( &self, path: impl Into, opts: Option, @@ -815,7 +941,17 @@ impl Directory { conn: self.conn.clone(), }; } - pub fn docker_build(&self, opts: Option) -> Container { + pub fn docker_build(&self) -> Container { + let mut query = self.selection.select("dockerBuild"); + + return Container { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn docker_build_opts(&self, opts: Option) -> Container { let mut query = self.selection.select("dockerBuild"); if let Some(opts) = opts { @@ -839,7 +975,13 @@ impl Directory { conn: self.conn.clone(), }; } - pub fn entries(&self, opts: Option) -> eyre::Result> { + pub fn entries(&self) -> eyre::Result> { + let mut query = self.selection.select("entries"); + + query.execute(&graphql_client(&self.conn)) + } + + pub fn entries_opts(&self, opts: Option) -> eyre::Result> { let mut query = self.selection.select("entries"); if let Some(opts) = opts { @@ -884,7 +1026,19 @@ impl Directory { conn: self.conn.clone(), }; } - pub fn pipeline( + pub fn pipeline(&self, name: impl Into) -> Directory { + let mut query = self.selection.select("pipeline"); + + query = query.arg("name", name.into()); + + return Directory { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn pipeline_opts( &self, name: impl Into, opts: Option, @@ -904,7 +1058,20 @@ impl Directory { conn: self.conn.clone(), }; } - pub fn with_directory( + pub fn with_directory(&self, path: impl Into, directory: DirectoryId) -> Directory { + let mut query = self.selection.select("withDirectory"); + + query = query.arg("path", path.into()); + query = query.arg("directory", directory); + + return Directory { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn with_directory_opts( &self, path: impl Into, directory: DirectoryId, @@ -929,7 +1096,20 @@ impl Directory { conn: self.conn.clone(), }; } - pub fn with_file( + pub fn with_file(&self, path: impl Into, source: FileId) -> Directory { + let mut query = self.selection.select("withFile"); + + query = query.arg("path", path.into()); + query = query.arg("source", source); + + return Directory { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn with_file_opts( &self, path: impl Into, source: FileId, @@ -951,7 +1131,19 @@ impl Directory { conn: self.conn.clone(), }; } - pub fn with_new_directory( + pub fn with_new_directory(&self, path: impl Into) -> Directory { + let mut query = self.selection.select("withNewDirectory"); + + query = query.arg("path", path.into()); + + return Directory { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn with_new_directory_opts( &self, path: impl Into, opts: Option, @@ -971,7 +1163,20 @@ impl Directory { conn: self.conn.clone(), }; } - pub fn with_new_file( + pub fn with_new_file(&self, path: impl Into, contents: impl Into) -> Directory { + let mut query = self.selection.select("withNewFile"); + + query = query.arg("path", path.into()); + query = query.arg("contents", contents.into()); + + return Directory { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn with_new_file_opts( &self, path: impl Into, contents: impl Into, @@ -1115,7 +1320,17 @@ impl GitRef { query.execute(&graphql_client(&self.conn)) } - pub fn tree(&self, opts: Option) -> Directory { + pub fn tree(&self) -> Directory { + let mut query = self.selection.select("tree"); + + return Directory { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn tree_opts(&self, opts: Option) -> Directory { let mut query = self.selection.select("tree"); if let Some(opts) = opts { @@ -1207,7 +1422,23 @@ pub struct HostWorkdirOpts<'a> { } impl Host { - pub fn directory(&self, path: impl Into, opts: Option) -> Directory { + pub fn directory(&self, path: impl Into) -> Directory { + let mut query = self.selection.select("directory"); + + query = query.arg("path", path.into()); + + return Directory { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn directory_opts( + &self, + path: impl Into, + opts: Option, + ) -> Directory { let mut query = self.selection.select("directory"); query = query.arg("path", path.into()); @@ -1248,7 +1479,17 @@ impl Host { conn: self.conn.clone(), }; } - pub fn workdir(&self, opts: Option) -> Directory { + pub fn workdir(&self) -> Directory { + let mut query = self.selection.select("workdir"); + + return Directory { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn workdir_opts(&self, opts: Option) -> Directory { let mut query = self.selection.select("workdir"); if let Some(opts) = opts { @@ -1399,7 +1640,17 @@ impl Query { conn: self.conn.clone(), }; } - pub fn container(&self, opts: Option) -> Container { + pub fn container(&self) -> Container { + let mut query = self.selection.select("container"); + + return Container { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn container_opts(&self, opts: Option) -> Container { let mut query = self.selection.select("container"); if let Some(opts) = opts { @@ -1422,7 +1673,17 @@ impl Query { query.execute(&graphql_client(&self.conn)) } - pub fn directory(&self, opts: Option) -> Directory { + pub fn directory(&self) -> Directory { + let mut query = self.selection.select("directory"); + + return Directory { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn directory_opts(&self, opts: Option) -> Directory { let mut query = self.selection.select("directory"); if let Some(opts) = opts { @@ -1448,7 +1709,19 @@ impl Query { conn: self.conn.clone(), }; } - pub fn git(&self, url: impl Into, opts: Option) -> GitRepository { + pub fn git(&self, url: impl Into) -> GitRepository { + let mut query = self.selection.select("git"); + + query = query.arg("url", url.into()); + + return GitRepository { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn git_opts(&self, url: impl Into, opts: Option) -> GitRepository { let mut query = self.selection.select("git"); query = query.arg("url", url.into()); @@ -1484,7 +1757,19 @@ impl Query { conn: self.conn.clone(), }; } - pub fn pipeline(&self, name: impl Into, opts: Option) -> Query { + pub fn pipeline(&self, name: impl Into) -> Query { + let mut query = self.selection.select("pipeline"); + + query = query.arg("name", name.into()); + + return Query { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn pipeline_opts(&self, name: impl Into, opts: Option) -> Query { let mut query = self.selection.select("pipeline"); query = query.arg("name", name.into()); @@ -1522,7 +1807,17 @@ impl Query { conn: self.conn.clone(), }; } - pub fn socket(&self, opts: Option) -> Socket { + pub fn socket(&self) -> Socket { + let mut query = self.selection.select("socket"); + + return Socket { + proc: self.proc.clone(), + selection: query, + conn: self.conn.clone(), + }; + } + + pub fn socket_opts(&self, opts: Option) -> Socket { let mut query = self.selection.select("socket"); if let Some(opts) = opts { diff --git a/crates/dagger-sdk/tests/mod.rs b/crates/dagger-sdk/tests/mod.rs index aac6c16..72e0b08 100644 --- a/crates/dagger-sdk/tests/mod.rs +++ b/crates/dagger-sdk/tests/mod.rs @@ -4,10 +4,10 @@ use dagger_sdk::{connect, ContainerExecOptsBuilder}; fn test_example_container() { let client = connect().unwrap(); - let alpine = client.container(None).from("alpine:3.16.2"); + let alpine = client.container().from("alpine:3.16.2"); let out = alpine - .exec(Some( + .exec_opts(Some( ContainerExecOptsBuilder::default() .args(vec!["cat", "/etc/alpine-release"]) .build()