Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
fix: add public tuple field and into func
Browse files Browse the repository at this point in the history
  • Loading branch information
kjuulh committed Mar 13, 2023
1 parent f679281 commit d7317e5
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 12 deletions.
8 changes: 7 additions & 1 deletion crates/dagger-codegen/src/rust/templates/scalar_tmpl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ pub fn render_scalar(t: &FullType) -> eyre::Result<rust::Tokens> {

Ok(quote! {
#[derive($serialize, $deserialize, PartialEq, Debug, Clone)]
pub struct $(t.name.pipe(|n|format_name(n)))(String);
pub struct $(t.name.pipe(|n|format_name(n)))(pub String);

impl Into<$(t.name.pipe(|n| format_name(n)))> for &str {
fn into(self) -> $(t.name.pipe(|n| format_name(n))) {
$(t.name.pipe(|n| format_name(n)))(self.to_string())
}
}
})
}
42 changes: 42 additions & 0 deletions crates/dagger-sdk/examples/iss-30-alt/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#![feature(async_closure)]

use dagger_sdk::{ContainerBuildOptsBuilder, HostDirectoryOpts, QueryContainerOpts};

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(QueryContainerOpts {
id: None,
platform: Some(platform.into()),
})
.build_opts(
context.id().await?,
ContainerBuildOptsBuilder::default()
.dockerfile(file)
.build()
.unwrap(),
)
.export("./test")
.await?;

println!("published image to: {:#?}", ref_);
}
}

Ok(())
}
64 changes: 53 additions & 11 deletions crates/dagger-sdk/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,70 @@ use std::sync::Arc;
use tokio::process::Child;

#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
pub struct CacheId(String);
pub struct CacheId(pub String);

impl Into<CacheId> for &str {
fn into(self) -> CacheId {
CacheId(self.to_string())
}
}
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
pub struct ContainerId(String);
pub struct ContainerId(pub String);

impl Into<ContainerId> for &str {
fn into(self) -> ContainerId {
ContainerId(self.to_string())
}
}
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
pub struct DirectoryId(String);
pub struct DirectoryId(pub String);

impl Into<DirectoryId> for &str {
fn into(self) -> DirectoryId {
DirectoryId(self.to_string())
}
}
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
pub struct FileId(String);
pub struct FileId(pub String);

impl Into<FileId> for &str {
fn into(self) -> FileId {
FileId(self.to_string())
}
}
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
pub struct Platform(String);
pub struct Platform(pub String);

impl Into<Platform> for &str {
fn into(self) -> Platform {
Platform(self.to_string())
}
}
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
pub struct SecretId(String);
pub struct SecretId(pub String);

impl Into<SecretId> for &str {
fn into(self) -> SecretId {
SecretId(self.to_string())
}
}
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
pub struct SocketId(String);
pub struct SocketId(pub String);

impl Into<SocketId> for &str {
fn into(self) -> SocketId {
SocketId(self.to_string())
}
}
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
pub struct BuildArg {
pub value: String,
pub name: String,
pub value: String,
}
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
pub struct PipelineLabel {
pub name: String,
pub value: String,
pub name: String,
}
#[derive(Debug, Clone)]
pub struct CacheVolume {
Expand Down Expand Up @@ -2764,12 +2806,12 @@ impl Socket {
}
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub enum CacheSharingMode {
SHARED,
PRIVATE,
LOCKED,
SHARED,
}
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub enum NetworkProtocol {
UDP,
TCP,
UDP,
}

0 comments on commit d7317e5

Please sign in to comment.