Compare commits

..

No commits in common. "756a0805336d477f33e7868570a89a86fc14c1dd" and "1b31331765403a93739e1e29750f70e7ef8df771" have entirely different histories.

20 changed files with 181 additions and 333 deletions

165
Cargo.lock generated
View File

@ -71,9 +71,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "block-buffer"
version = "0.10.4"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e"
dependencies = [
"generic-array",
]
@ -121,9 +121,9 @@ dependencies = [
[[package]]
name = "clap"
version = "4.1.8"
version = "4.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5"
checksum = "ec0b0588d44d4d63a87dbd75c136c166bbfd9a86a31cb89e09906521c7d3f5e3"
dependencies = [
"bitflags",
"clap_lex",
@ -134,9 +134,9 @@ dependencies = [
[[package]]
name = "clap_lex"
version = "0.3.2"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09"
checksum = "783fe232adfca04f90f56201b26d79682d4cd2625e0bc7290b95123afe558ade"
dependencies = [
"os_str_bytes",
]
@ -262,9 +262,11 @@ dependencies = [
name = "dagger-core"
version = "0.2.8"
dependencies = [
"clap",
"dirs",
"eyre",
"flate2",
"genco",
"graphql-introspection-query",
"graphql_client",
"hex",
@ -290,6 +292,7 @@ dependencies = [
"dirs",
"eyre",
"flate2",
"genco",
"graphql-introspection-query",
"graphql_client",
"hex",
@ -306,7 +309,7 @@ dependencies = [
[[package]]
name = "dagger-sdk"
version = "0.2.19"
version = "0.2.17"
dependencies = [
"base64",
"dagger-core",
@ -324,9 +327,9 @@ dependencies = [
[[package]]
name = "darling"
version = "0.14.4"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850"
checksum = "c0808e1bd8671fb44a113a14e13497557533369847788fa2ae912b6ebfce9fa8"
dependencies = [
"darling_core",
"darling_macro",
@ -334,9 +337,9 @@ dependencies = [
[[package]]
name = "darling_core"
version = "0.14.4"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0"
checksum = "001d80444f28e193f30c2f293455da62dcf9a6b29918a4253152ae2b1de592cb"
dependencies = [
"fnv",
"ident_case",
@ -348,9 +351,9 @@ dependencies = [
[[package]]
name = "darling_macro"
version = "0.14.4"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e"
checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685"
dependencies = [
"darling_core",
"quote",
@ -743,9 +746,9 @@ dependencies = [
[[package]]
name = "h2"
version = "0.3.16"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d"
checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4"
dependencies = [
"bytes",
"fnv",
@ -835,9 +838,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
[[package]]
name = "hyper"
version = "0.14.25"
version = "0.14.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899"
checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c"
dependencies = [
"bytes",
"futures-channel",
@ -913,9 +916,9 @@ dependencies = [
[[package]]
name = "io-lifetimes"
version = "1.0.6"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3"
checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3"
dependencies = [
"libc",
"windows-sys 0.45.0",
@ -929,9 +932,9 @@ checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146"
[[package]]
name = "is-terminal"
version = "0.4.4"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857"
checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef"
dependencies = [
"hermit-abi 0.3.1",
"io-lifetimes",
@ -950,9 +953,9 @@ dependencies = [
[[package]]
name = "itoa"
version = "1.0.6"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440"
[[package]]
name = "js-sys"
@ -971,9 +974,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.140"
version = "0.2.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
[[package]]
name = "libz-sys"
@ -1230,18 +1233,18 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.52"
version = "1.0.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224"
checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.26"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
dependencies = [
"proc-macro2",
]
@ -1298,9 +1301,18 @@ dependencies = [
[[package]]
name = "relative-path"
version = "1.8.0"
version = "1.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bf2521270932c3c7bed1a59151222bd7643c79310f2916f01925e1e16255698"
checksum = "d3bf6b372449361333ac1f498b7edae4dd5e70dccd7c0c2a7c7bce8f05ede648"
[[package]]
name = "remove_dir_all"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [
"winapi",
]
[[package]]
name = "reqwest"
@ -1350,9 +1362,9 @@ checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
[[package]]
name = "rustix"
version = "0.36.9"
version = "0.36.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc"
checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644"
dependencies = [
"bitflags",
"errno",
@ -1364,9 +1376,9 @@ dependencies = [
[[package]]
name = "ryu"
version = "1.0.13"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041"
checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde"
[[package]]
name = "schannel"
@ -1408,18 +1420,18 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.156"
version = "1.0.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4"
checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.156"
version = "1.0.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d"
checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e"
dependencies = [
"proc-macro2",
"quote",
@ -1428,9 +1440,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.94"
version = "1.0.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea"
checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76"
dependencies = [
"itoa",
"ryu",
@ -1495,9 +1507,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "socket2"
version = "0.4.9"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662"
checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd"
dependencies = [
"libc",
"winapi",
@ -1511,9 +1523,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "1.0.109"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
dependencies = [
"proc-macro2",
"quote",
@ -1533,15 +1545,16 @@ dependencies = [
[[package]]
name = "tempfile"
version = "3.4.0"
version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95"
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
dependencies = [
"cfg-if",
"fastrand",
"libc",
"redox_syscall",
"rustix",
"windows-sys 0.42.0",
"remove_dir_all",
"winapi",
]
[[package]]
@ -1555,18 +1568,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.39"
version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c"
checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.39"
version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e"
checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f"
dependencies = [
"proc-macro2",
"quote",
@ -1600,9 +1613,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
version = "1.26.0"
version = "1.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64"
checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af"
dependencies = [
"autocfg",
"bytes",
@ -1615,7 +1628,7 @@ dependencies = [
"signal-hook-registry",
"socket2",
"tokio-macros",
"windows-sys 0.45.0",
"windows-sys 0.42.0",
]
[[package]]
@ -1715,15 +1728,15 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]]
name = "unicode-bidi"
version = "0.3.11"
version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c"
checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58"
[[package]]
name = "unicode-ident"
version = "1.0.8"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
[[package]]
name = "unicode-normalization"
@ -1946,9 +1959,9 @@ dependencies = [
[[package]]
name = "windows-targets"
version = "0.42.2"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
@ -1961,45 +1974,45 @@ dependencies = [
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.2"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.2"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
[[package]]
name = "windows_i686_gnu"
version = "0.42.2"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
[[package]]
name = "windows_i686_msvc"
version = "0.42.2"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.2"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.2"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.2"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
[[package]]
name = "winreg"

View File

@ -1,20 +1,42 @@
[package]
name = "dagger-rs"
version = "0.2.10"
edition = "2021"
readme = "README.md"
license-file = "LICENSE.MIT"
description = "A dagger sdk for rust, written in rust"
repository = "https://github.com/kjuulh/dagger-rs"
publish = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[workspace]
members = [
"crates/dagger-codegen",
"crates/dagger-sdk",
"crates/dagger-core",
"crates/dagger-rs",
"ci",
]
[workspace.dependencies]
[dependencies]
dagger-codegen = { path = "crates/dagger-codegen", version = "^0.2.5" }
dagger-core = { path = "crates/dagger-core", version = "^0.2.8" }
dagger-rs = { path = "crates/dagger-rs", version = "^0.2.10" }
dagger-sdk = { path = "crates/dagger-sdk", version = "^0.2.19" }
clap = "4.1.6"
dirs = "4.0.0"
eyre = "0.6.8"
color-eyre = "0.6.2"
flate2 = { version = "1.0.25", features = ["zlib"] }
genco = "0.17.3"
graphql-introspection-query = "0.2.0"
graphql_client = { version = "0.12.0", features = ["reqwest"] }
hex = "0.4.3"
hex-literal = "0.3.4"
platform-info = "1.0.2"
reqwest = { version = "0.11.14", features = ["stream", "deflate"] }
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.93"
sha2 = "0.10.6"
tar = "0.4.38"
tempfile = "3.3.0"
color-eyre = "0.6.2"
tokio = { version = "1.25.0", features = ["full"] }

View File

@ -3,19 +3,6 @@ command = "cargo"
args = ["run", "-p", "ci", "--", "codegen"]
workspace = false
[tasks.local_codegen]
command = "cargo"
args = [
"run",
"-p",
"dagger-rs",
"--",
"generate",
"--output",
"crates/dagger-sdk/src/gen.rs",
]
workspace = false
[tasks.build]
command = "cargo"
args = ["run", "-p", "ci", "--", "ci"]
@ -33,10 +20,6 @@ args = ["fix", "--workspace", "--allow-dirty"]
dependencies = ["fmt"]
workspace = false
[tasks.gen]
dependencies = ["local_codegen", "fmt", "fix"]
workspace = false
[tasks.release_crate]
command = "cargo"
args = [

View File

@ -8,6 +8,6 @@ edition = "2021"
[dependencies]
clap = "4.1.6"
color-eyre = "0.6.2"
dagger-sdk = { path = "../crates/dagger-sdk/", version = "^0.2.19" }
dagger-sdk = { path = "../crates/dagger-sdk/", version = "^0.2.17" }
eyre = "0.6.8"
tokio = { version = "1.25.0", features = ["full"] }

View File

@ -10,15 +10,12 @@ publish = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dagger-core = { workspace = true }
eyre = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
genco = "0.17.3"
convert_case = "0.6.0"
itertools = "0.10.5"
dagger-core = { path = "../dagger-core", version = "^0.2.8" }
[dev-dependencies]
eyre = "0.6.8"
genco = "0.17.3"
itertools = "0.10.5"
pretty_assertions = "1.3.0"
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.93"

View File

@ -196,22 +196,6 @@ pub fn type_ref_is_scalar(type_ref: &TypeRef) -> bool {
.unwrap_or(false)
}
pub fn type_ref_is_enum(type_ref: &TypeRef) -> bool {
let mut type_ref = type_ref.clone();
if type_ref
.kind
.pipe(|k| *k == __TypeKind::NON_NULL)
.unwrap_or(false)
{
type_ref = *type_ref.of_type.unwrap().clone();
}
type_ref
.kind
.pipe(|k| *k == __TypeKind::ENUM)
.unwrap_or(false)
}
pub fn type_ref_is_object(type_ref: &TypeRef) -> bool {
let mut type_ref = type_ref.clone();
if type_ref

View File

@ -3,11 +3,10 @@ use dagger_core::introspection::{FullTypeFields, TypeRef};
use genco::prelude::rust;
use genco::quote;
use genco::tokens::quoted;
use itertools::Itertools;
use crate::functions::{
type_field_has_optional, type_ref_is_enum, type_ref_is_list, type_ref_is_list_of_objects,
type_ref_is_object, type_ref_is_optional, type_ref_is_scalar, CommonFunctions, Scalar,
type_field_has_optional, type_ref_is_list, type_ref_is_list_of_objects, type_ref_is_object,
type_ref_is_optional, type_ref_is_scalar, CommonFunctions, Scalar,
};
use crate::utility::OptionExt;
@ -134,12 +133,6 @@ fn render_required_args(_funcs: &CommonFunctions, field: &FullTypeFields) -> Opt
}
}
if type_ref_is_enum(&s.input_value.type_) {
return Some(quote! {
query = query.arg_enum($(quoted(name)), $(n));
})
}
if type_ref_is_list(&s.input_value.type_) {
let inner = *s
.input_value
@ -194,14 +187,6 @@ fn render_optional_args(_funcs: &CommonFunctions, field: &FullTypeFields) -> Opt
let n = format_struct_name(&s.input_value.name);
let name = &s.input_value.name;
if type_ref_is_enum(&s.input_value.type_) {
return Some(quote! {
if let Some($(&n)) = opts.$(&n) {
query = query.arg_enum($(quoted(name)), $(n));
}
});
}
Some(quote! {
if let Some($(&n)) = opts.$(&n) {
query = query.arg($(quoted(name)), $(&n));
@ -406,7 +391,6 @@ pub fn format_optional_args(
.map(|t| {
t.into_iter()
.filter(|t| type_ref_is_optional(&t.input_value.type_))
.sorted_by_key(|val| &val.input_value.name)
.collect::<Vec<_>>()
})
.pipe(|t| render_optional_field_args(funcs, t))

View File

@ -1,7 +1,6 @@
use dagger_core::introspection::FullType;
use genco::prelude::rust;
use genco::quote;
use itertools::Itertools;
fn render_enum_values(values: &FullType) -> Option<rust::Tokens> {
let values = values
@ -11,7 +10,6 @@ fn render_enum_values(values: &FullType) -> Option<rust::Tokens> {
.map(|values| {
values
.into_iter()
.sorted_by_key(|a| &a.name)
.map(|val| quote! { $(val.name.as_ref()), })
})
.flatten()

View File

@ -1,7 +1,6 @@
use dagger_core::introspection::{FullType, FullTypeInputFields};
use genco::prelude::rust;
use genco::quote;
use itertools::Itertools;
use crate::functions::CommonFunctions;
use crate::rust::functions::{format_name, format_struct_name};
@ -21,10 +20,7 @@ pub fn render_input_fields(
funcs: &CommonFunctions,
fields: &[FullTypeInputFields],
) -> Option<rust::Tokens> {
let rendered_fields = fields
.iter()
.sorted_by_key(|val| &val.input_value.name)
.map(|f| render_input_field(funcs, f));
let rendered_fields = fields.iter().map(|f| render_input_field(funcs, f));
if rendered_fields.len() == 0 {
None

View File

@ -10,19 +10,20 @@ publish = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
eyre = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
tokio = { workspace = true }
clap = "4.1.6"
dirs = "4.0.0"
eyre = "0.6.8"
flate2 = { version = "1.0.25", features = ["zlib"] }
genco = "0.17.3"
graphql-introspection-query = "0.2.0"
graphql_client = { version = "0.12.0", features = ["reqwest"] }
hex = "0.4.3"
hex-literal = "0.3.4"
platform-info = "1.0.2"
reqwest = { version = "0.11.14", features = ["stream", "deflate"] }
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.93"
sha2 = "0.10.6"
tar = "0.4.38"
tempfile = "3.3.0"
tokio = { version = "1.25.0", features = ["full"] }

View File

@ -1,34 +0,0 @@
[package]
name = "dagger-rs"
version = "0.2.10"
edition = "2021"
readme = "README.md"
license-file = "LICENSE.MIT"
description = "A dagger sdk for rust, written in rust"
repository = "https://github.com/kjuulh/dagger-rs"
publish = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dagger-core = { workspace = true }
dagger-codegen = { workspace = true }
eyre = { workspace = true }
color-eyre = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
tokio = { workspace = true }
clap = "4.1.6"
dirs = "4.0.0"
flate2 = { version = "1.0.25", features = ["zlib"] }
graphql-introspection-query = "0.2.0"
graphql_client = { version = "0.12.0", features = ["reqwest"] }
hex = "0.4.3"
hex-literal = "0.3.4"
platform-info = "1.0.2"
reqwest = { version = "0.11.14", features = ["stream", "deflate"] }
sha2 = "0.10.6"
tar = "0.4.38"
tempfile = "3.3.0"

View File

@ -6,43 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v0.2.19 (2023-03-14)
### Chore
- <csr-id-6629d2db4fbc7cdba9b2e4a241e4b0a2592cf384/> fix release version
### Bug Fixes
- <csr-id-8fd6bb983ef00b1aa2cf1ba3088028329033c38f/> serialization of enum args for graphql
### Commit Statistics
<csr-read-only-do-not-edit/>
- 2 commits contributed to the release.
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
- 1 unique issue was worked on: [#34](https://github.com/kjuulh/dagger-rs/issues/34)
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **[#34](https://github.com/kjuulh/dagger-rs/issues/34)**
- serialization of enum args for graphql ([`8fd6bb9`](https://github.com/kjuulh/dagger-rs/commit/8fd6bb983ef00b1aa2cf1ba3088028329033c38f))
* **Uncategorized**
- fix release version ([`6629d2d`](https://github.com/kjuulh/dagger-rs/commit/6629d2db4fbc7cdba9b2e4a241e4b0a2592cf384))
</details>
## v0.2.17 (2023-03-13)
<csr-id-f67928155f02076cbb41abd4010523879ff3caf1/>
<csr-id-2cc0231c5f29993081f0f7e15e44cac95a7d6086/>
<csr-id-9ba01396cb44ee02cf7a16008e3f0bdae9f78754/>
<csr-id-e9e35edb1cb67eee8cc033212aba3b1888def78f/>
### Bug Fixes
- <csr-id-1bfd084cd28e2b984c61de7f3f9a065cc41be007/> make sure tests have a command to execute
@ -65,7 +30,7 @@ and this project adheres to
<csr-read-only-do-not-edit/>
- 10 commits contributed to the release over the course of 2 calendar days.
- 9 commits contributed to the release over the course of 2 calendar days.
- 2 days passed between releases.
- 9 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
@ -77,7 +42,6 @@ and this project adheres to
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-sdk v0.2.17 ([`a8e6dde`](https://github.com/kjuulh/dagger-rs/commit/a8e6dde615029d9a94d159ed84b5373121cd201f))
- make sure tests have a command to execute ([`1bfd084`](https://github.com/kjuulh/dagger-rs/commit/1bfd084cd28e2b984c61de7f3f9a065cc41be007))
- remove unused imports ([`5593fce`](https://github.com/kjuulh/dagger-rs/commit/5593fce2e16e0aa97a2e6843f15d3bb1121048f5))
- remove export and instead use exitcode ([`2cc0231`](https://github.com/kjuulh/dagger-rs/commit/2cc0231c5f29993081f0f7e15e44cac95a7d6086))

View File

@ -1,6 +1,6 @@
[package]
name = "dagger-sdk"
version = "0.2.19"
version = "0.2.17"
edition = "2021"
readme = "README.md"
license-file = "LICENSE.MIT"
@ -11,16 +11,15 @@ publish = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dagger-core = { workspace = true }
eyre = { workspace = true }
tokio = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
dagger-core = { path = "../dagger-core", version = "^0.2.8" }
base64 = "0.21.0"
eyre = "0.6.8"
futures = "0.3.27"
gql_client = "1.0.7"
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.93"
tokio = { version = "1.25.0", features = ["full"] }
derive_builder = "0.12.0"
[dev-dependencies]

View File

@ -111,8 +111,8 @@ pub struct BuildArg {
}
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
pub struct PipelineLabel {
pub name: String,
pub value: String,
pub name: String,
}
#[derive(Debug, Clone)]
pub struct CacheVolume {
@ -137,13 +137,13 @@ pub struct Container {
#[derive(Builder, Debug, PartialEq)]
pub struct ContainerBuildOpts<'a> {
/// Additional build arguments.
#[builder(setter(into, strip_option), default)]
pub build_args: Option<Vec<BuildArg>>,
/// Path to the Dockerfile to use.
/// Default: './Dockerfile'.
#[builder(setter(into, strip_option), default)]
pub dockerfile: Option<&'a str>,
/// Additional build arguments.
#[builder(setter(into, strip_option), default)]
pub build_args: Option<Vec<BuildArg>>,
/// Target build stage to build.
#[builder(setter(into, strip_option), default)]
pub target: Option<&'a str>,
@ -162,20 +162,20 @@ pub struct ContainerExecOpts<'a> {
/// Command to run instead of the container's default command (e.g., ["run", "main.go"]).
#[builder(setter(into, strip_option), default)]
pub args: Option<Vec<&'a str>>,
/// Content to write to the command's standard input before closing (e.g., "Hello world").
#[builder(setter(into, strip_option), default)]
pub stdin: Option<&'a str>,
/// Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
#[builder(setter(into, strip_option), default)]
pub redirect_stdout: Option<&'a str>,
/// Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
#[builder(setter(into, strip_option), default)]
pub redirect_stderr: Option<&'a str>,
/// Provide dagger access to the executed command.
/// Do not use this option unless you trust the command being executed.
/// The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
#[builder(setter(into, strip_option), default)]
pub experimental_privileged_nesting: Option<bool>,
/// Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
#[builder(setter(into, strip_option), default)]
pub redirect_stderr: Option<&'a str>,
/// Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
#[builder(setter(into, strip_option), default)]
pub redirect_stdout: Option<&'a str>,
/// Content to write to the command's standard input before closing (e.g., "Hello world").
#[builder(setter(into, strip_option), default)]
pub stdin: Option<&'a str>,
}
#[derive(Builder, Debug, PartialEq)]
pub struct ContainerExportOpts {
@ -217,6 +217,15 @@ pub struct ContainerWithDirectoryOpts<'a> {
}
#[derive(Builder, Debug, PartialEq)]
pub struct ContainerWithExecOpts<'a> {
/// Content to write to the command's standard input before closing (e.g., "Hello world").
#[builder(setter(into, strip_option), default)]
pub stdin: Option<&'a str>,
/// Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
#[builder(setter(into, strip_option), default)]
pub redirect_stdout: Option<&'a str>,
/// Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
#[builder(setter(into, strip_option), default)]
pub redirect_stderr: Option<&'a str>,
/// Provides dagger access to the executed command.
/// Do not use this option unless you trust the command being executed.
/// The command being executed WILL BE GRANTED FULL ACCESS TO YOUR HOST FILESYSTEM.
@ -228,24 +237,15 @@ pub struct ContainerWithExecOpts<'a> {
/// when absolutely necessary and only with trusted commands.
#[builder(setter(into, strip_option), default)]
pub insecure_root_capabilities: Option<bool>,
/// Redirect the command's standard error to a file in the container (e.g., "/tmp/stderr").
#[builder(setter(into, strip_option), default)]
pub redirect_stderr: Option<&'a str>,
/// Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
#[builder(setter(into, strip_option), default)]
pub redirect_stdout: Option<&'a str>,
/// Content to write to the command's standard input before closing (e.g., "Hello world").
#[builder(setter(into, strip_option), default)]
pub stdin: Option<&'a str>,
}
#[derive(Builder, Debug, PartialEq)]
pub struct ContainerWithExposedPortOpts<'a> {
/// Optional port description
#[builder(setter(into, strip_option), default)]
pub description: Option<&'a str>,
/// Transport layer network protocol
#[builder(setter(into, strip_option), default)]
pub protocol: Option<NetworkProtocol>,
/// Optional port description
#[builder(setter(into, strip_option), default)]
pub description: Option<&'a str>,
}
#[derive(Builder, Debug, PartialEq)]
pub struct ContainerWithFileOpts {
@ -256,12 +256,12 @@ pub struct ContainerWithFileOpts {
}
#[derive(Builder, Debug, PartialEq)]
pub struct ContainerWithMountedCacheOpts {
/// Sharing mode of the cache volume.
#[builder(setter(into, strip_option), default)]
pub sharing: Option<CacheSharingMode>,
/// Identifier of the directory to use as the cache volume's root.
#[builder(setter(into, strip_option), default)]
pub source: Option<DirectoryId>,
/// Sharing mode of the cache volume.
#[builder(setter(into, strip_option), default)]
pub sharing: Option<CacheSharingMode>,
}
#[derive(Builder, Debug, PartialEq)]
pub struct ContainerWithNewFileOpts<'a> {
@ -955,7 +955,7 @@ impl Container {
query = query.arg("port", port);
if let Some(protocol) = opts.protocol {
query = query.arg_enum("protocol", protocol);
query = query.arg("protocol", protocol);
}
if let Some(description) = opts.description {
query = query.arg("description", description);
@ -1085,7 +1085,7 @@ impl Container {
query = query.arg("source", source);
}
if let Some(sharing) = opts.sharing {
query = query.arg_enum("sharing", sharing);
query = query.arg("sharing", sharing);
}
return Container {
@ -1395,7 +1395,7 @@ impl Container {
query = query.arg("port", port);
if let Some(protocol) = opts.protocol {
query = query.arg_enum("protocol", protocol);
query = query.arg("protocol", protocol);
}
return Container {
@ -1485,9 +1485,6 @@ pub struct Directory {
#[derive(Builder, Debug, PartialEq)]
pub struct DirectoryDockerBuildOpts<'a> {
/// Build arguments to use in the build.
#[builder(setter(into, strip_option), default)]
pub build_args: Option<Vec<BuildArg>>,
/// Path to the Dockerfile to use (e.g., "frontend.Dockerfile").
/// Defaults: './Dockerfile'.
#[builder(setter(into, strip_option), default)]
@ -1495,6 +1492,9 @@ pub struct DirectoryDockerBuildOpts<'a> {
/// The platform to build.
#[builder(setter(into, strip_option), default)]
pub platform: Option<Platform>,
/// Build arguments to use in the build.
#[builder(setter(into, strip_option), default)]
pub build_args: Option<Vec<BuildArg>>,
/// Target build stage to build.
#[builder(setter(into, strip_option), default)]
pub target: Option<&'a str>,
@ -2073,10 +2073,10 @@ pub struct GitRef {
#[derive(Builder, Debug, PartialEq)]
pub struct GitRefTreeOpts<'a> {
#[builder(setter(into, strip_option), default)]
pub ssh_auth_socket: Option<SocketId>,
#[builder(setter(into, strip_option), default)]
pub ssh_known_hosts: Option<&'a str>,
#[builder(setter(into, strip_option), default)]
pub ssh_auth_socket: Option<SocketId>,
}
impl GitRef {
@ -2480,12 +2480,12 @@ pub struct QueryDirectoryOpts {
}
#[derive(Builder, Debug, PartialEq)]
pub struct QueryGitOpts {
/// A service which must be started before the repo is fetched.
#[builder(setter(into, strip_option), default)]
pub experimental_service_host: Option<ContainerId>,
/// Set to true to keep .git directory.
#[builder(setter(into, strip_option), default)]
pub keep_git_dir: Option<bool>,
/// A service which must be started before the repo is fetched.
#[builder(setter(into, strip_option), default)]
pub experimental_service_host: Option<ContainerId>,
}
#[derive(Builder, Debug, PartialEq)]
pub struct QueryHttpOpts {
@ -2848,9 +2848,9 @@ impl Socket {
}
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub enum CacheSharingMode {
LOCKED,
PRIVATE,
SHARED,
PRIVATE,
LOCKED,
}
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub enum NetworkProtocol {

View File

@ -68,32 +68,6 @@ impl Selection {
s
}
pub fn arg_enum<S>(&self, name: &str, value: S) -> Selection
where
S: Serialize,
{
let mut s = self.clone();
let val = serde_json::to_string(&value).unwrap();
let val = val[1..val.len() - 1].to_string();
println!("test");
println!("{}", val);
match s.args.as_mut() {
Some(args) => {
let _ = args.insert(name.to_string(), val);
}
None => {
let mut hm = HashMap::new();
let _ = hm.insert(name.to_string(), val);
s.args = Some(hm);
}
}
s
}
pub fn build(&self) -> eyre::Result<String> {
let mut fields = vec!["query".to_string()];
@ -102,7 +76,7 @@ impl Selection {
if let Some(args) = sel.args {
let actualargs = args
.iter()
.map(|(name, arg)| format!("{name}:{}", arg.as_str()))
.map(|(name, arg)| format!("{name}:{arg}"))
.collect::<Vec<_>>();
query = query.add(&format!("({})", actualargs.join(", ")));
@ -125,9 +99,6 @@ impl Selection {
{
let query = self.build()?;
let qbs = query.as_str();
println!("{}", qbs);
let resp: Option<serde_json::Value> = match gql_client.query(&query).await {
Ok(r) => r,
Err(e) => eyre::bail!(e),

View File

@ -1,29 +0,0 @@
use dagger_sdk::{ContainerWithExposedPortOpts, NetworkProtocol};
#[tokio::test]
async fn test_issue_30_alt() -> eyre::Result<()> {
let client = dagger_sdk::connect().await?;
client
.container()
.from("denoland/deno:debian-1.30.3")
.with_exposed_port_opts(
53,
ContainerWithExposedPortOpts {
protocol: Some(NetworkProtocol::TCP),
description: None,
},
)
.with_exposed_port_opts(
53,
ContainerWithExposedPortOpts {
protocol: Some(NetworkProtocol::UDP),
description: None,
},
)
.with_exec(vec!["echo", "hello"])
.exit_code()
.await?;
Ok(())
}

View File

@ -1,2 +1 @@
mod iss_30;
mod iss_33;