mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2024-11-29 10:12:27 +01:00
fix(sdk): without phantom data
This commit is contained in:
parent
c14cd64453
commit
b25b350d90
@ -28,7 +28,7 @@ fn main() -> eyre::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn release(client: Arc<Query>, subm: &clap::ArgMatches) -> Result<(), color_eyre::Report> {
|
fn release(client: Arc<Query>, _subm: &clap::ArgMatches) -> Result<(), color_eyre::Report> {
|
||||||
let src_dir = client.host().directory(
|
let src_dir = client.host().directory(
|
||||||
".".into(),
|
".".into(),
|
||||||
Some(HostDirectoryOpts {
|
Some(HostDirectoryOpts {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use dagger_core::introspection::{FullType, FullTypeFields, FullTypeFieldsArgs};
|
use dagger_core::introspection::{FullType, FullTypeFields, FullTypeFieldsArgs};
|
||||||
use genco::prelude::rust;
|
use genco::prelude::rust;
|
||||||
use genco::quote;
|
use genco::quote;
|
||||||
|
use itertools::Itertools;
|
||||||
|
|
||||||
use crate::functions::{type_ref_is_optional, CommonFunctions};
|
use crate::functions::{type_ref_is_optional, CommonFunctions};
|
||||||
use crate::rust::functions::{
|
use crate::rust::functions::{
|
||||||
@ -64,10 +65,10 @@ fn render_optional_arg(funcs: &CommonFunctions, field: &FullTypeFields) -> Optio
|
|||||||
let builder = rust::import("derive_builder", "Builder");
|
let builder = rust::import("derive_builder", "Builder");
|
||||||
let phantom_data = rust::import("std::marker", "PhantomData");
|
let phantom_data = rust::import("std::marker", "PhantomData");
|
||||||
|
|
||||||
if let Some(fields) = fields {
|
if let Some((fields, contains_lifetime)) = fields {
|
||||||
Some(quote! {
|
Some(quote! {
|
||||||
#[derive($builder, Debug, PartialEq)]
|
#[derive($builder, Debug, PartialEq)]
|
||||||
pub struct $output_type<'a> {
|
pub struct $output_type$(if contains_lifetime => <'a>) {
|
||||||
//#[builder(default, setter(skip))]
|
//#[builder(default, setter(skip))]
|
||||||
//pub marker: $(phantom_data)<&'a ()>,
|
//pub marker: $(phantom_data)<&'a ()>,
|
||||||
$fields
|
$fields
|
||||||
@ -81,20 +82,28 @@ fn render_optional_arg(funcs: &CommonFunctions, field: &FullTypeFields) -> Optio
|
|||||||
fn render_optional_field_args(
|
fn render_optional_field_args(
|
||||||
funcs: &CommonFunctions,
|
funcs: &CommonFunctions,
|
||||||
args: &Vec<&FullTypeFieldsArgs>,
|
args: &Vec<&FullTypeFieldsArgs>,
|
||||||
) -> Option<rust::Tokens> {
|
) -> Option<(rust::Tokens, bool)> {
|
||||||
if args.len() == 0 {
|
if args.len() == 0 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
let mut contains_lifetime = false;
|
||||||
let rendered_args = args.into_iter().map(|a| &a.input_value).map(|a| {
|
let rendered_args = args.into_iter().map(|a| &a.input_value).map(|a| {
|
||||||
|
let type_ = funcs.format_immutable_input_type(&a.type_);
|
||||||
|
if type_.contains("str") {
|
||||||
|
contains_lifetime = true;
|
||||||
|
}
|
||||||
quote! {
|
quote! {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option))]
|
||||||
pub $(format_struct_name(&a.name)): Option<$(funcs.format_immutable_input_type(&a.type_))>,
|
pub $(format_struct_name(&a.name)): Option<$(type_)>,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Some(quote! {
|
Some((
|
||||||
|
quote! {
|
||||||
$(for arg in rendered_args join ($['\r']) => $arg)
|
$(for arg in rendered_args join ($['\r']) => $arg)
|
||||||
})
|
},
|
||||||
|
contains_lifetime,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_functions(funcs: &CommonFunctions, fields: &Vec<FullTypeFields>) -> Option<rust::Tokens> {
|
fn render_functions(funcs: &CommonFunctions, fields: &Vec<FullTypeFields>) -> Option<rust::Tokens> {
|
||||||
|
@ -8,7 +8,6 @@ fn main() -> eyre::Result<()> {
|
|||||||
Some(HostDirectoryOpts {
|
Some(HostDirectoryOpts {
|
||||||
exclude: Some(vec!["node_modules".into(), "ci/".into()]),
|
exclude: Some(vec!["node_modules".into(), "ci/".into()]),
|
||||||
include: None,
|
include: None,
|
||||||
marker: std::marker::PhantomData,
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ fn main() -> eyre::Result<()> {
|
|||||||
Some(HostDirectoryOpts {
|
Some(HostDirectoryOpts {
|
||||||
exclude: Some(vec!["node_modules", "ci/"]),
|
exclude: Some(vec!["node_modules", "ci/"]),
|
||||||
include: None,
|
include: None,
|
||||||
marker: std::marker::PhantomData,
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ fn main() -> eyre::Result<()> {
|
|||||||
Some(HostDirectoryOpts {
|
Some(HostDirectoryOpts {
|
||||||
exclude: Some(vec!["node_modules", "ci/"]),
|
exclude: Some(vec!["node_modules", "ci/"]),
|
||||||
include: None,
|
include: None,
|
||||||
marker: std::marker::PhantomData,
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ fn main() -> eyre::Result<()> {
|
|||||||
Some(HostDirectoryOpts {
|
Some(HostDirectoryOpts {
|
||||||
exclude: Some(vec!["node_modules", "ci/"]),
|
exclude: Some(vec!["node_modules", "ci/"]),
|
||||||
include: None,
|
include: None,
|
||||||
marker: std::marker::PhantomData,
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ pub struct ContainerExecOpts<'a> {
|
|||||||
pub experimental_privileged_nesting: Option<bool>,
|
pub experimental_privileged_nesting: Option<bool>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerExportOpts<'a> {
|
pub struct ContainerExportOpts {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option))]
|
||||||
pub platform_variants: Option<Vec<ContainerId>>,
|
pub platform_variants: Option<Vec<ContainerId>>,
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ pub struct ContainerPipelineOpts<'a> {
|
|||||||
pub description: Option<&'a str>,
|
pub description: Option<&'a str>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerPublishOpts<'a> {
|
pub struct ContainerPublishOpts {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option))]
|
||||||
pub platform_variants: Option<Vec<ContainerId>>,
|
pub platform_variants: Option<Vec<ContainerId>>,
|
||||||
}
|
}
|
||||||
@ -105,12 +105,12 @@ pub struct ContainerWithExecOpts<'a> {
|
|||||||
pub experimental_privileged_nesting: Option<bool>,
|
pub experimental_privileged_nesting: Option<bool>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerWithFileOpts<'a> {
|
pub struct ContainerWithFileOpts {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option))]
|
||||||
pub permissions: Option<isize>,
|
pub permissions: Option<isize>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct ContainerWithMountedCacheOpts<'a> {
|
pub struct ContainerWithMountedCacheOpts {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option))]
|
||||||
pub source: Option<DirectoryId>,
|
pub source: Option<DirectoryId>,
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option))]
|
||||||
@ -777,17 +777,17 @@ pub struct DirectoryWithDirectoryOpts<'a> {
|
|||||||
pub include: Option<Vec<&'a str>>,
|
pub include: Option<Vec<&'a str>>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct DirectoryWithFileOpts<'a> {
|
pub struct DirectoryWithFileOpts {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option))]
|
||||||
pub permissions: Option<isize>,
|
pub permissions: Option<isize>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct DirectoryWithNewDirectoryOpts<'a> {
|
pub struct DirectoryWithNewDirectoryOpts {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option))]
|
||||||
pub permissions: Option<isize>,
|
pub permissions: Option<isize>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct DirectoryWithNewFileOpts<'a> {
|
pub struct DirectoryWithNewFileOpts {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option))]
|
||||||
pub permissions: Option<isize>,
|
pub permissions: Option<isize>,
|
||||||
}
|
}
|
||||||
@ -1360,19 +1360,19 @@ pub struct Query {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct QueryContainerOpts<'a> {
|
pub struct QueryContainerOpts {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option))]
|
||||||
pub id: Option<ContainerId>,
|
pub id: Option<ContainerId>,
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option))]
|
||||||
pub platform: Option<Platform>,
|
pub platform: Option<Platform>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct QueryDirectoryOpts<'a> {
|
pub struct QueryDirectoryOpts {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option))]
|
||||||
pub id: Option<DirectoryId>,
|
pub id: Option<DirectoryId>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct QueryGitOpts<'a> {
|
pub struct QueryGitOpts {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option))]
|
||||||
pub keep_git_dir: Option<bool>,
|
pub keep_git_dir: Option<bool>,
|
||||||
}
|
}
|
||||||
@ -1382,7 +1382,7 @@ pub struct QueryPipelineOpts<'a> {
|
|||||||
pub description: Option<&'a str>,
|
pub description: Option<&'a str>,
|
||||||
}
|
}
|
||||||
#[derive(Builder, Debug, PartialEq)]
|
#[derive(Builder, Debug, PartialEq)]
|
||||||
pub struct QuerySocketOpts<'a> {
|
pub struct QuerySocketOpts {
|
||||||
#[builder(setter(into, strip_option))]
|
#[builder(setter(into, strip_option))]
|
||||||
pub id: Option<SocketId>,
|
pub id: Option<SocketId>,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user