mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-08-18 13:03:28 +02:00
Compare commits
8 Commits
dagger-sdk
...
issue/30
Author | SHA1 | Date | |
---|---|---|---|
c3a43d1a80
|
|||
01f807b150
|
|||
cbdac7fef5
|
|||
1f26415759
|
|||
471caf276b
|
|||
e3579a35e0
|
|||
5bc517e68f
|
|||
deda62253e
|
@@ -11,6 +11,18 @@ pub fn render_scalar(t: &FullType) -> eyre::Result<rust::Tokens> {
|
|||||||
|
|
||||||
Ok(quote! {
|
Ok(quote! {
|
||||||
#[derive($serialize, $deserialize, PartialEq, Debug, Clone)]
|
#[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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<$(t.name.pipe(|n| format_name(n)))> for String {
|
||||||
|
fn into(self) -> $(t.name.pipe(|n| format_name(n))) {
|
||||||
|
$(t.name.pipe(|n| format_name(n)))(self.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -7,28 +7,112 @@ use std::sync::Arc;
|
|||||||
use tokio::process::Child;
|
use tokio::process::Child;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
#[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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<CacheId> for String {
|
||||||
|
fn into(self) -> CacheId {
|
||||||
|
CacheId(self.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
#[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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<ContainerId> for String {
|
||||||
|
fn into(self) -> ContainerId {
|
||||||
|
ContainerId(self.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
#[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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<DirectoryId> for String {
|
||||||
|
fn into(self) -> DirectoryId {
|
||||||
|
DirectoryId(self.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
#[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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<FileId> for String {
|
||||||
|
fn into(self) -> FileId {
|
||||||
|
FileId(self.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
#[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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<Platform> for String {
|
||||||
|
fn into(self) -> Platform {
|
||||||
|
Platform(self.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
#[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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<SecretId> for String {
|
||||||
|
fn into(self) -> SecretId {
|
||||||
|
SecretId(self.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
#[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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<SocketId> for String {
|
||||||
|
fn into(self) -> SocketId {
|
||||||
|
SocketId(self.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
||||||
pub struct BuildArg {
|
pub struct BuildArg {
|
||||||
pub value: String,
|
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
pub value: String,
|
||||||
}
|
}
|
||||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
|
||||||
pub struct PipelineLabel {
|
pub struct PipelineLabel {
|
||||||
pub name: String,
|
|
||||||
pub value: String,
|
pub value: String,
|
||||||
|
pub name: String,
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct CacheVolume {
|
pub struct CacheVolume {
|
||||||
@@ -2764,12 +2848,12 @@ impl Socket {
|
|||||||
}
|
}
|
||||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
||||||
pub enum CacheSharingMode {
|
pub enum CacheSharingMode {
|
||||||
|
SHARED,
|
||||||
PRIVATE,
|
PRIVATE,
|
||||||
LOCKED,
|
LOCKED,
|
||||||
SHARED,
|
|
||||||
}
|
}
|
||||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
||||||
pub enum NetworkProtocol {
|
pub enum NetworkProtocol {
|
||||||
UDP,
|
|
||||||
TCP,
|
TCP,
|
||||||
|
UDP,
|
||||||
}
|
}
|
||||||
|
47
crates/dagger-sdk/tests/issues/iss_30.rs
Normal file
47
crates/dagger-sdk/tests/issues/iss_30.rs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
use dagger_sdk::{QueryContainerOpts, QueryContainerOptsBuilder};
|
||||||
|
|
||||||
|
static PLATFORMS: [&str; 2] = ["linux/arm64", "linux/x86_64"];
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_issue_30_alt() -> eyre::Result<()> {
|
||||||
|
let client = dagger_sdk::connect().await?;
|
||||||
|
|
||||||
|
for platform in PLATFORMS {
|
||||||
|
let ref_ = client
|
||||||
|
.container_opts(QueryContainerOpts {
|
||||||
|
id: None,
|
||||||
|
platform: Some(platform.to_string().into()),
|
||||||
|
})
|
||||||
|
.from("alpine")
|
||||||
|
.with_exec(vec!["echo", "'hello'"])
|
||||||
|
.exit_code()
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
println!("published image to: {:#?}", ref_);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_issue_30() -> eyre::Result<()> {
|
||||||
|
let client = dagger_sdk::connect().await?;
|
||||||
|
|
||||||
|
for platform in PLATFORMS {
|
||||||
|
let ref_ = client
|
||||||
|
.container_opts(
|
||||||
|
QueryContainerOptsBuilder::default()
|
||||||
|
.platform(platform)
|
||||||
|
.build()
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.from("alpine")
|
||||||
|
.with_exec(vec!["echo", "'hello'"])
|
||||||
|
.exit_code()
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
println!("published image to: {:#?}", ref_);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
1
crates/dagger-sdk/tests/issues/mod.rs
Normal file
1
crates/dagger-sdk/tests/issues/mod.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
mod iss_30;
|
@@ -1,3 +1,5 @@
|
|||||||
|
mod issues;
|
||||||
|
|
||||||
use dagger_sdk::{connect, ContainerExecOptsBuilder};
|
use dagger_sdk::{connect, ContainerExecOptsBuilder};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user