Compare commits

...

50 Commits

Author SHA1 Message Date
81f50a2760 feat: rename projects to point to github/kjuulh/dagger-sdk 2023-03-18 15:23:24 +01:00
79d931e908 feat: with loggers 2023-03-14 23:21:14 +01:00
756a080533 fix: stable input fields and args 2023-03-14 22:21:35 +01:00
ea27fa8168 chore: fmt 2023-03-14 22:21:35 +01:00
71f98d0293 fix: stable enum entries 2023-03-14 22:21:35 +01:00
6ef4bdf587 refactor: add basic cargo make gen command 2023-03-14 22:01:20 +01:00
b55bcc159f refactor: move dagger-rs and adopt workspace.deps 2023-03-14 22:01:20 +01:00
76fab3f466 Release dagger-sdk v0.2.19 2023-03-14 15:00:47 +01:00
6629d2db4f chore: fix release version 2023-03-14 15:00:43 +01:00
8fd6bb983e fix: serialization of enum args for graphql (#34) 2023-03-14 13:56:49 +00:00
1b31331765 feat: update readme 2023-03-13 23:57:32 +01:00
a8e6dde615 Release dagger-sdk v0.2.17 2023-03-13 21:09:18 +01:00
1bfd084cd2 fix: make sure tests have a command to execute 2023-03-13 21:07:14 +01:00
5593fce2e1 fix: remove unused imports 2023-03-13 21:07:14 +01:00
2cc0231c5f refactor: remove export and instead use exitcode 2023-03-13 21:07:14 +01:00
9ba01396cb refactor: move issues to actual tests and refactor 2023-03-13 21:07:14 +01:00
c025d17424 fix: add support for String as well 2023-03-13 21:07:14 +01:00
e9e35edb1c refactor: move issues to another folder 2023-03-13 21:07:14 +01:00
d7317e5cf3 fix: add public tuple field and into func 2023-03-13 21:07:14 +01:00
f67928155f replication(issue-30): initial issue 2023-03-13 21:07:14 +01:00
Renovate Bot
44fa0240f8 fix(deps): update rust crate futures to 0.3.27 2023-03-11 18:21:37 +01:00
62de24153a docs: add basic contributing 2023-03-10 23:49:26 +01:00
9513bb5653 docs: add architecture 2023-03-10 23:46:12 +01:00
6b43d5bc36 fix: proper readme 2023-03-10 23:44:36 +01:00
f390eac29f Release dagger-core v0.2.8, dagger-sdk v0.2.16 2023-03-10 23:40:02 +01:00
e642778d90 chore: fix tasks 2023-03-10 23:39:23 +01:00
7133bfae95 feat: with dagger-engine v.0.4.0 2023-03-10 23:27:15 +01:00
41b20b6268 feat: bump version 2023-03-10 23:27:15 +01:00
13b7805e7e docs(sdk): fix missing await in connect 2023-02-25 02:42:34 +01:00
4381af0295 feat: add tests to sdk 2023-02-25 02:33:30 +01:00
5f9b3a19c0 feat: set internal warnings as errors 2023-02-25 02:01:13 +01:00
f9e7af931d feat: introduce tests again 2023-02-25 01:47:57 +01:00
ecca036bc6 fix(sdk): fix builder pattern to actually work with default values
In previous versions the builder pattern required all values to be set.
This has not been fixed, so that default values are allowed.
2023-02-25 01:47:57 +01:00
6a9a560cdc Release dagger-core v0.2.7, dagger-sdk v0.2.15 2023-02-25 00:11:35 +01:00
e578b0e371 fix: set deserialize on enums as well 2023-02-25 00:10:46 +01:00
3e8ca8d86e feat: update to dagger-v0.3.13
https://github.com/dagger/dagger/releases/tag/v0.3.13
2023-02-25 00:10:46 +01:00
88b055cb47 Release dagger-sdk v0.2.14 2023-02-22 23:09:36 +01:00
e331ca0035 chore(sdk): fix whitespace 2023-02-22 23:09:20 +01:00
456f48389b Release dagger-codegen v0.2.8, dagger-sdk v0.2.13 2023-02-22 22:38:42 +01:00
7c3654d276 chore(sdk): ran clippy 2023-02-22 22:38:33 +01:00
266ad32dff feat(sdk): with clone 2023-02-22 22:38:15 +01:00
7179f8b598 Release dagger-core v0.2.6, dagger-codegen v0.2.7, dagger-sdk v0.2.12 2023-02-20 12:07:33 +01:00
1f77d90c0f chore(sdk): ran clippy 2023-02-20 11:54:44 +01:00
8dfecf976c fix(core): cli session keep session alive 2023-02-20 11:54:22 +01:00
085a998bc6 fix(ci): set path to local dagger sdk 2023-02-20 11:45:59 +01:00
1725c5188e Release dagger-core v0.2.5, dagger-sdk v0.2.12, dagger-codegen v0.2.7 2023-02-20 11:42:14 +01:00
a13a2a9ecb fix(all): race condition in process 2023-02-20 11:42:03 +01:00
b86710d71e revert disable caching 2023-02-20 11:28:24 +01:00
08a2e30967 disable cache 2023-02-20 10:56:56 +01:00
b552dc5d75 chore(ci): with dagger v0.2.11 2023-02-20 10:50:48 +01:00
70 changed files with 32521 additions and 1179 deletions

12
ARCHITECTURE.md Normal file
View File

@@ -0,0 +1,12 @@
# Architecture
- `.` Root project mainly used for generating the CLI, which in turn is used to
bootstrap the code generation from `dagger`
- `crates/dagger-core` Contains all base types used during actual usage. This is
where the primary logic lives in which the user interacts (\*disclaimer: most
stuff haven't moved in here yet.)
- `crates/dagger-sdk` Contains the actual sdk in which the user interacts,
`dagger-core` is reexported through this API as well.
- `crates/dagger-codegen` This is the bulk of the work, it takes the input
graphql and spits out the API in which the user interacts, this is heavily
inspired by other `dagger-sdk's`. It primarily turns graphql into rust code.

11
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,11 @@
# Contributing
The sdk is still quite young, so feel free to either:
- Refactor
- Document
- Improve the code
Feel free to ping me on discord @Hermansen#4325, or just create an issue if
there is a missing feature, or you'd like some mentorship in getting into the
code

403
Cargo.lock generated
View File

@@ -71,9 +71,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "block-buffer"
version = "0.10.3"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [
"generic-array",
]
@@ -114,16 +114,16 @@ version = "0.1.0"
dependencies = [
"clap",
"color-eyre",
"dagger-sdk 0.2.10",
"dagger-sdk",
"eyre",
"tokio",
]
[[package]]
name = "clap"
version = "4.1.6"
version = "4.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0b0588d44d4d63a87dbd75c136c166bbfd9a86a31cb89e09906521c7d3f5e3"
checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5"
dependencies = [
"bitflags",
"clap_lex",
@@ -134,9 +134,9 @@ dependencies = [
[[package]]
name = "clap_lex"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "783fe232adfca04f90f56201b26d79682d4cd2625e0bc7290b95123afe558ade"
checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09"
dependencies = [
"os_str_bytes",
]
@@ -244,12 +244,37 @@ dependencies = [
"syn",
]
[[package]]
name = "dagger-bootstrap"
version = "0.2.10"
dependencies = [
"clap",
"color-eyre",
"dagger-codegen",
"dagger-core",
"dirs",
"eyre",
"flate2",
"graphql-introspection-query",
"graphql_client",
"hex",
"hex-literal",
"platform-info",
"reqwest",
"serde",
"serde_json",
"sha2",
"tar",
"tempfile",
"tokio",
]
[[package]]
name = "dagger-codegen"
version = "0.2.6"
version = "0.2.8"
dependencies = [
"convert_case",
"dagger-core 0.2.4",
"dagger-core",
"eyre",
"genco",
"itertools",
@@ -260,64 +285,11 @@ dependencies = [
[[package]]
name = "dagger-core"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e18641c2b159006cab7d750c05d3272f0cabfe9532df20b47076353aa73bf1e"
version = "0.2.8"
dependencies = [
"clap",
"dirs",
"eyre",
"flate2",
"genco",
"graphql-introspection-query",
"graphql_client",
"hex",
"hex-literal",
"platform-info",
"reqwest",
"serde",
"serde_json",
"sha2",
"tar",
"tempfile",
"tokio",
]
[[package]]
name = "dagger-core"
version = "0.2.4"
dependencies = [
"clap",
"dirs",
"eyre",
"flate2",
"genco",
"graphql-introspection-query",
"graphql_client",
"hex",
"hex-literal",
"platform-info",
"reqwest",
"serde",
"serde_json",
"sha2",
"tar",
"tempfile",
"tokio",
]
[[package]]
name = "dagger-rs"
version = "0.2.10"
dependencies = [
"clap",
"color-eyre",
"dagger-codegen",
"dagger-core 0.2.4",
"dirs",
"eyre",
"flate2",
"genco",
"graphql-introspection-query",
"graphql_client",
"hex",
@@ -330,31 +302,16 @@ dependencies = [
"tar",
"tempfile",
"tokio",
"tracing",
"tracing-subscriber",
]
[[package]]
name = "dagger-sdk"
version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af3b3404f52ddf367998475bc48e5a08699950ee7ba54ba334b7ffe1681df0c5"
version = "0.2.19"
dependencies = [
"base64",
"dagger-core 0.2.3",
"derive_builder",
"eyre",
"futures",
"gql_client",
"serde",
"serde_json",
"tokio",
]
[[package]]
name = "dagger-sdk"
version = "0.2.11"
dependencies = [
"base64",
"dagger-core 0.2.4",
"dagger-core",
"derive_builder",
"eyre",
"futures",
@@ -365,13 +322,16 @@ dependencies = [
"serde",
"serde_json",
"tokio",
"tracing",
"tracing-subscriber",
"tracing-test",
]
[[package]]
name = "darling"
version = "0.14.3"
version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0808e1bd8671fb44a113a14e13497557533369847788fa2ae912b6ebfce9fa8"
checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850"
dependencies = [
"darling_core",
"darling_macro",
@@ -379,9 +339,9 @@ dependencies = [
[[package]]
name = "darling_core"
version = "0.14.3"
version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "001d80444f28e193f30c2f293455da62dcf9a6b29918a4253152ae2b1de592cb"
checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0"
dependencies = [
"fnv",
"ident_case",
@@ -393,9 +353,9 @@ dependencies = [
[[package]]
name = "darling_macro"
version = "0.14.3"
version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685"
checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e"
dependencies = [
"darling_core",
"quote",
@@ -579,9 +539,9 @@ dependencies = [
[[package]]
name = "futures"
version = "0.3.26"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84"
checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549"
dependencies = [
"futures-channel",
"futures-core",
@@ -594,9 +554,9 @@ dependencies = [
[[package]]
name = "futures-channel"
version = "0.3.26"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5"
checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac"
dependencies = [
"futures-core",
"futures-sink",
@@ -604,15 +564,15 @@ dependencies = [
[[package]]
name = "futures-core"
version = "0.3.26"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608"
checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd"
[[package]]
name = "futures-executor"
version = "0.3.26"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e"
checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83"
dependencies = [
"futures-core",
"futures-task",
@@ -621,15 +581,15 @@ dependencies = [
[[package]]
name = "futures-io"
version = "0.3.26"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531"
checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91"
[[package]]
name = "futures-macro"
version = "0.3.26"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70"
checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6"
dependencies = [
"proc-macro2",
"quote",
@@ -638,21 +598,21 @@ dependencies = [
[[package]]
name = "futures-sink"
version = "0.3.26"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364"
checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2"
[[package]]
name = "futures-task"
version = "0.3.26"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366"
checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879"
[[package]]
name = "futures-util"
version = "0.3.26"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1"
checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab"
dependencies = [
"futures-channel",
"futures-core",
@@ -788,9 +748,9 @@ dependencies = [
[[package]]
name = "h2"
version = "0.3.15"
version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4"
checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d"
dependencies = [
"bytes",
"fnv",
@@ -880,9 +840,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
[[package]]
name = "hyper"
version = "0.14.24"
version = "0.14.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c"
checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899"
dependencies = [
"bytes",
"futures-channel",
@@ -958,9 +918,9 @@ dependencies = [
[[package]]
name = "io-lifetimes"
version = "1.0.5"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3"
checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3"
dependencies = [
"libc",
"windows-sys 0.45.0",
@@ -974,9 +934,9 @@ checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146"
[[package]]
name = "is-terminal"
version = "0.4.3"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef"
checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857"
dependencies = [
"hermit-abi 0.3.1",
"io-lifetimes",
@@ -995,9 +955,9 @@ dependencies = [
[[package]]
name = "itoa"
version = "1.0.5"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440"
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
[[package]]
name = "js-sys"
@@ -1016,9 +976,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.139"
version = "0.2.140"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
[[package]]
name = "libz-sys"
@@ -1056,6 +1016,15 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "matchers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
"regex-automata",
]
[[package]]
name = "memchr"
version = "2.5.0"
@@ -1107,6 +1076,16 @@ dependencies = [
"tempfile",
]
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
dependencies = [
"overload",
"winapi",
]
[[package]]
name = "num_cpus"
version = "1.15.0"
@@ -1192,6 +1171,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "owo-colors"
version = "3.5.0"
@@ -1275,18 +1260,18 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.51"
version = "1.0.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6"
checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.23"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc"
dependencies = [
"proc-macro2",
]
@@ -1342,20 +1327,35 @@ dependencies = [
]
[[package]]
name = "relative-path"
version = "1.7.3"
name = "regex"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3bf6b372449361333ac1f498b7edae4dd5e70dccd7c0c2a7c7bce8f05ede648"
checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733"
dependencies = [
"regex-syntax",
]
[[package]]
name = "remove_dir_all"
version = "0.5.3"
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"winapi",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
[[package]]
name = "relative-path"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bf2521270932c3c7bed1a59151222bd7643c79310f2916f01925e1e16255698"
[[package]]
name = "reqwest"
version = "0.11.14"
@@ -1404,9 +1404,9 @@ checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
[[package]]
name = "rustix"
version = "0.36.8"
version = "0.36.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644"
checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc"
dependencies = [
"bitflags",
"errno",
@@ -1418,9 +1418,9 @@ dependencies = [
[[package]]
name = "ryu"
version = "1.0.12"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde"
checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041"
[[package]]
name = "schannel"
@@ -1462,18 +1462,18 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.152"
version = "1.0.156"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.152"
version = "1.0.156"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e"
checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d"
dependencies = [
"proc-macro2",
"quote",
@@ -1482,9 +1482,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.93"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76"
checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea"
dependencies = [
"itoa",
"ryu",
@@ -1549,9 +1549,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "socket2"
version = "0.4.7"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd"
checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662"
dependencies = [
"libc",
"winapi",
@@ -1565,9 +1565,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "1.0.107"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
@@ -1587,16 +1587,15 @@ dependencies = [
[[package]]
name = "tempfile"
version = "3.3.0"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95"
dependencies = [
"cfg-if",
"fastrand",
"libc",
"redox_syscall",
"remove_dir_all",
"winapi",
"rustix",
"windows-sys 0.42.0",
]
[[package]]
@@ -1610,18 +1609,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.38"
version = "1.0.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0"
checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.38"
version = "1.0.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f"
checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e"
dependencies = [
"proc-macro2",
"quote",
@@ -1655,9 +1654,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
version = "1.25.0"
version = "1.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af"
checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64"
dependencies = [
"autocfg",
"bytes",
@@ -1670,7 +1669,7 @@ dependencies = [
"signal-hook-registry",
"socket2",
"tokio-macros",
"windows-sys 0.42.0",
"windows-sys 0.45.0",
]
[[package]]
@@ -1721,10 +1720,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
dependencies = [
"cfg-if",
"log",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.30"
@@ -1745,15 +1757,56 @@ dependencies = [
"tracing-subscriber",
]
[[package]]
name = "tracing-log"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
dependencies = [
"lazy_static",
"log",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70"
dependencies = [
"matchers",
"nu-ansi-term",
"once_cell",
"regex",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
]
[[package]]
name = "tracing-test"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a2c0ff408fe918a94c428a3f2ad04e4afd5c95bbc08fcf868eff750c15728a4"
dependencies = [
"lazy_static",
"tracing-core",
"tracing-subscriber",
"tracing-test-macro",
]
[[package]]
name = "tracing-test-macro"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "258bc1c4f8e2e73a977812ab339d503e6feeb92700f6d07a6de4d321522d5c08"
dependencies = [
"lazy_static",
"quote",
"syn",
]
[[package]]
@@ -1770,15 +1823,15 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]]
name = "unicode-bidi"
version = "0.3.10"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58"
checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c"
[[package]]
name = "unicode-ident"
version = "1.0.6"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4"
[[package]]
name = "unicode-normalization"
@@ -2001,9 +2054,9 @@ dependencies = [
[[package]]
name = "windows-targets"
version = "0.42.1"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
@@ -2016,45 +2069,45 @@ dependencies = [
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.1"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.1"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
[[package]]
name = "windows_i686_gnu"
version = "0.42.1"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
[[package]]
name = "windows_i686_msvc"
version = "0.42.1"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.1"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.1"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.1"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
[[package]]
name = "winreg"

View File

@@ -1,42 +1,25 @@
[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-bootstrap",
"ci",
]
[dependencies]
[workspace.dependencies]
dagger-codegen = { path = "crates/dagger-codegen", version = "^0.2.5" }
dagger-core = { path = "crates/dagger-core", version = "^0.2.3" }
dagger-core = { path = "crates/dagger-core", version = "^0.2.8" }
dagger-bootstrap = { path = "crates/dagger-bootstrap", 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"
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"] }
color-eyre = "0.6.2"
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"] }
tracing = { version = "0.1.37", features = ["log"] }
tracing-subscriber = { version = "0.3.16", features = [
"tracing-log",
"tracing",
] }

60
Makefile.toml Normal file
View File

@@ -0,0 +1,60 @@
[tasks.codegen]
command = "cargo"
args = ["run", "-p", "ci", "--", "codegen"]
workspace = false
[tasks.local_codegen]
command = "cargo"
args = [
"run",
"-p",
"dagger-bootstrap",
"--",
"generate",
"--output",
"crates/dagger-sdk/src/gen.rs",
]
workspace = false
[tasks.build]
command = "cargo"
args = ["run", "-p", "ci", "--", "ci"]
dependencies = ["codegen"]
workspace = false
[tasks.fmt]
command = "cargo"
args = ["fmt", "--all"]
workspace = false
[tasks.fix]
command = "cargo"
args = ["fix", "--workspace", "--allow-dirty"]
dependencies = ["fmt"]
workspace = false
[tasks.gen]
dependencies = ["local_codegen", "fmt", "fix"]
workspace = false
[tasks.release_crate]
command = "cargo"
args = [
"smart-release",
"--allow-fully-generated-changelogs",
"--update-crates-index",
"dagger-sdk",
]
dependencies = ["codegen", "fix"]
workspace = false
[tasks.release_crate_commit]
command = "cargo"
args = [
"smart-release",
"-e",
"--allow-fully-generated-changelogs",
"--update-crates-index",
"dagger-sdk",
]
workspace = false

View File

@@ -1,40 +1,55 @@
# dagger-rs
# dagger-sdk
A dagger sdk written in rust for rust.
# Usage
## Examples
See [dagger-sdk](./crates/dagger-sdk/README.md)
See [examples](./crates/dagger-sdk/examples/)
### Status
Run them like so
- [x] dagger cli downloader
- [x] dagger network session
- [x] graphql rust codegen (User API)
- [x] Scalars
- [x] Enums
- [x] Input
- [x] Objects
- [x] Implement context and querier
- [x] Marshaller
- [x] Querier
- [x] Context
- [x] Deserializer for nested response (bind)
- [x] Add codegen to hook into querier
- [x] fix build / release cycle
- [x] general api stabilisation
- [x] document usage
- [x] make async variant
```bash
cargo run --example first-pipeline
```
## Architecture
The examples match the folder name in each directory in examples
- `.` Root project mainly used for generating the CLI, which in turn is used to
bootstrap the code generation from `dagger`
- `crates/dagger-core` Contains all base types used during actual usage. This is
where the primary logic lives in which the user interacts (\*disclaimer: most
stuff haven't moved in here yet.)
- `crates/dagger-sdk` Contains the actual sdk in which the user interacts,
`dagger-core` is reexported through this API as well.
- `crates/dagger-codegen` This is the bulk of the work, it takes the input
graphql and spits out the API in which the user interacts, this is heavily
inspired by other `dagger-sdk's`. It primarily turns graphql into rust code.
## Install
Simply install like:
```bash
cargo add dagger-sdk
```
### Usage
```rust
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect().await?;
let version = client
.container()
.from("golang:1.19")
.with_exec(vec!["go", "version"])
.stdout()
.await?;
println!("Hello from Dagger and {}", version.trim());
Ok(())
}
```
And run it like a normal application:
```bash
cargo run
```
### Contributing
See [CONTRIBUTING](./CONTRIBUTING.md)
or just cargo make codegen

View File

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

View File

@@ -1,5 +1,6 @@
use std::sync::Arc;
use clap::ArgMatches;
use dagger_sdk::{Container, HostDirectoryOpts, Query};
#[tokio::main]
@@ -10,6 +11,7 @@ async fn main() -> eyre::Result<()> {
.subcommand_required(true)
.subcommand(clap::Command::new("pr"))
.subcommand(clap::Command::new("release"))
.subcommand(clap::Command::new("codegen"))
.get_matches();
let client = dagger_sdk::connect().await?;
@@ -20,6 +22,7 @@ async fn main() -> eyre::Result<()> {
return validate_pr(client, base).await;
}
Some(("release", subm)) => return release(client, subm).await,
Some(("codegen", subm)) => return run_codegen(client, subm).await,
Some(_) => {
panic!("invalid subcommand selected!")
}
@@ -29,6 +32,42 @@ async fn main() -> eyre::Result<()> {
}
}
async fn run_codegen(client: Arc<Query>, _subm: &ArgMatches) -> eyre::Result<()> {
let docker_cli = client
.container()
.from("docker:cli")
.file("/usr/local/bin/docker");
let socket = client.host().unix_socket("/var/run/docker.sock");
let container = get_dependencies(client).await?;
let generated_image = container
.with_exec(vec!["mkdir", "-p", "/mnt/output"])
.with_mounted_file("/usr/bin/docker", docker_cli.id().await?)
.with_unix_socket("/var/run/docker.sock", socket.id().await?)
.with_exec(vec![
"cargo",
"run",
"--",
"generate",
"--output",
"crates/dagger-sdk/gen.rs",
])
.with_exec(vec!["cargo", "fmt", "--all"])
.with_exec(vec!["cargo", "fix", "--workspace", "--allow-dirty"])
.with_exec(vec!["cargo", "fmt", "--all"])
.with_exec(vec!["mv", "crates/dagger-sdk/gen.rs", "/mnt/output/gen.rs"]);
let _ = generated_image.exit_code().await?;
generated_image
.file("/mnt/output/gen.rs")
.export("crates/dagger-sdk/src/gen.rs")
.await?;
Ok(())
}
async fn release(client: Arc<Query>, _subm: &clap::ArgMatches) -> Result<(), color_eyre::Report> {
let src_dir = client.host().directory_opts(
".",
@@ -51,7 +90,7 @@ async fn release(client: Arc<Query>, _subm: &clap::ArgMatches) -> Result<(), col
"--execute",
"--allow-fully-generated-changelogs",
"--no-changelog-preview",
"dagger-rs",
"dagger-sdk",
"dagger-sdk",
]);
let exit = container.exit_code().await?;
@@ -87,14 +126,14 @@ async fn get_dependencies(client: Arc<Query>) -> eyre::Result<Container> {
);
let cache_cargo_index_dir = client.cache_volume("cargo_index");
let cache_cargo_deps = client.cache_volume("cargo_deps");
let _cache_cargo_deps = client.cache_volume("cargo_deps");
let cache_cargo_bin = client.cache_volume("cargo_bin_cache");
let minio_url = "https://github.com/mozilla/sccache/releases/download/v0.3.3/sccache-v0.3.3-x86_64-unknown-linux-musl.tar.gz";
let base_image = client
.container()
.from("rust:latest")
.from("rustlang/rust:nightly")
.with_workdir("app")
.with_exec(vec!["apt-get", "update"])
.with_exec(vec!["apt-get", "install", "--yes", "libpq-dev", "wget"])
@@ -110,7 +149,7 @@ async fn get_dependencies(client: Arc<Query>) -> eyre::Result<Container> {
"/usr/local/bin/sccache",
])
.with_exec(vec!["chmod", "+x", "/usr/local/bin/sccache"])
.with_env_variable("RUSTC_WRAPPER", "/usr/local/bin/sccache")
//.with_env_variable("RUSTC_WRAPPER", "/usr/local/bin/sccache")
.with_env_variable(
"AWS_ACCESS_KEY_ID",
std::env::var("AWS_ACCESS_KEY_ID").unwrap_or("".into()),
@@ -152,8 +191,7 @@ async fn get_dependencies(client: Arc<Query>) -> eyre::Result<Container> {
"--recipe-path",
"recipe.json",
])
.with_mounted_cache("/app/", cache_cargo_deps.id().await?)
.with_mounted_directory("/app/", src_dir.id().await?)
.with_directory("/app/", src_dir.id().await?)
.with_exec(vec!["cargo", "build", "--all", "--release"]);
return Ok(builder_start);
@@ -165,8 +203,21 @@ async fn select_base_image(client: Arc<Query>) -> eyre::Result<Container> {
src_dir
}
async fn validate_pr(_client: Arc<Query>, container: Container) -> eyre::Result<()> {
//let container = container.with_exec(vec!["cargo", "test", "--all"], None);
async fn validate_pr(client: Arc<Query>, container: Container) -> eyre::Result<()> {
let exit = container.exit_code().await?;
if exit != 0 {
eyre::bail!("container failed with non-zero exit code");
}
let docker_cli = client
.container()
.from("docker:cli")
.file("/usr/local/bin/docker");
let socket = client.host().unix_socket("/var/run/docker.sock");
let container = container
.with_mounted_file("/usr/bin/docker", docker_cli.id().await?)
.with_unix_socket("/var/run/docker.sock", socket.id().await?)
.with_exec(vec!["cargo", "test", "--all"]);
let exit = container.exit_code().await?;
if exit != 0 {

View File

@@ -0,0 +1,34 @@
[package]
name = "dagger-bootstrap"
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-sdk"
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

@@ -5,6 +5,57 @@ All notable changes to this project will be documented in this file.
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.8 (2023-02-22)
### New Features
- <csr-id-266ad32dff4c8957c7cdd291f9ef6f8a8c1d055c/> with clone
### Commit Statistics
<csr-read-only-do-not-edit/>
- 1 commit contributed to the release.
- 2 days passed between releases.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- with clone ([`266ad32`](https://github.com/kjuulh/dagger-rs/commit/266ad32dff4c8957c7cdd291f9ef6f8a8c1d055c))
</details>
## v0.2.7 (2023-02-20)
### Bug Fixes
- <csr-id-a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de/> race condition in process
### Commit Statistics
<csr-read-only-do-not-edit/>
- 3 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.6, dagger-codegen v0.2.7, dagger-sdk v0.2.12 ([`7179f8b`](https://github.com/kjuulh/dagger-rs/commit/7179f8b598ef04e62925e39d3f55740253c01686))
- Release dagger-core v0.2.5, dagger-sdk v0.2.12, dagger-codegen v0.2.7 ([`1725c51`](https://github.com/kjuulh/dagger-rs/commit/1725c5188e8a81069ec4a4de569484c921a94927))
- race condition in process ([`a13a2a9`](https://github.com/kjuulh/dagger-rs/commit/a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de))
</details>
## v0.2.6 (2023-02-20)
<csr-id-803cfc4f8c4d72ab7d011be5523b3bfc6039de39/>
@@ -17,7 +68,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<csr-read-only-do-not-edit/>
- 2 commits contributed to the release.
- 3 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
@@ -28,6 +79,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`f869e57`](https://github.com/kjuulh/dagger-rs/commit/f869e574dd788cd60e5b1b5d502bec68e300694c))
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`17ec62a`](https://github.com/kjuulh/dagger-rs/commit/17ec62a5d58232ff57391523b9851fb7b07d02ab))
- ran clippy ([`803cfc4`](https://github.com/kjuulh/dagger-rs/commit/803cfc4f8c4d72ab7d011be5523b3bfc6039de39))
</details>

View File

@@ -1,21 +1,24 @@
[package]
name = "dagger-codegen"
version = "0.2.6"
version = "0.2.8"
edition = "2021"
readme = "README.md"
license-file = "LICENSE.MIT"
description = "dagger sdk codegen library"
repository = "https://github.com/kjuulh/dagger-rs"
repository = "https://github.com/kjuulh/dagger-sdk"
publish = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
convert_case = "0.6.0"
dagger-core = { path = "../dagger-core", version = "^0.2.4" }
dagger-core = { workspace = true }
eyre = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
eyre = "0.6.8"
genco = "0.17.3"
convert_case = "0.6.0"
itertools = "0.10.5"
[dev-dependencies]
pretty_assertions = "1.3.0"
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.93"

View File

@@ -153,6 +153,7 @@ impl From<&TypeRef> for Scalar {
}
}
#[allow(dead_code)]
pub fn get_type_from_name<'t>(types: &'t [FullType], name: &'t str) -> Option<&'t FullType> {
types
.into_iter()
@@ -195,6 +196,22 @@ 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
@@ -258,6 +275,7 @@ pub fn input_values_has_optionals(input_values: &[&InputValue]) -> bool {
> 0
}
#[allow(dead_code)]
pub fn input_values_is_empty(input_values: &[InputValue]) -> bool {
input_values.len() > 0
}

View File

@@ -1,3 +1,5 @@
#![deny(warnings)]
mod functions;
mod generator;
pub mod rust;

View File

@@ -3,10 +3,11 @@ 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_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_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,
};
use crate::utility::OptionExt;
@@ -133,6 +134,12 @@ 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
@@ -187,6 +194,14 @@ 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));
@@ -391,6 +406,7 @@ 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,6 +1,7 @@
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
@@ -10,6 +11,7 @@ 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()
@@ -26,9 +28,10 @@ fn render_enum_values(values: &FullType) -> Option<rust::Tokens> {
pub fn render_enum(t: &FullType) -> eyre::Result<rust::Tokens> {
let serialize = rust::import("serde", "Serialize");
let deserialize = rust::import("serde", "Deserialize");
Ok(quote! {
#[derive($serialize, Clone, PartialEq, Debug)]
#[derive($serialize, $deserialize, Clone, PartialEq, Debug)]
pub enum $(t.name.as_ref()) {
$(render_enum_values(t))
}

View File

@@ -1,6 +1,7 @@
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};
@@ -20,7 +21,10 @@ pub fn render_input_fields(
funcs: &CommonFunctions,
fields: &[FullTypeInputFields],
) -> Option<rust::Tokens> {
let rendered_fields = fields.iter().map(|f| render_input_field(funcs, f));
let rendered_fields = fields
.iter()
.sorted_by_key(|val| &val.input_value.name)
.map(|f| render_input_field(funcs, f));
if rendered_fields.len() == 0 {
None

View File

@@ -1,9 +1,8 @@
use dagger_core::introspection::{FullType, FullTypeFields, FullTypeFieldsArgs};
use genco::prelude::rust;
use genco::quote;
use itertools::Itertools;
use crate::functions::{CommonFunctions};
use crate::functions::CommonFunctions;
use crate::rust::functions::{
field_options_struct_name, format_function, format_name, format_optional_args,
format_struct_comment, format_struct_name,
@@ -12,11 +11,12 @@ use crate::utility::OptionExt;
pub fn render_object(funcs: &CommonFunctions, t: &FullType) -> eyre::Result<rust::Tokens> {
let selection = rust::import("crate::querybuilder", "Selection");
let child = rust::import("std::process", "Child");
let child = rust::import("tokio::process", "Child");
let conn = rust::import("dagger_core::connect_params", "ConnectParams");
let arc = rust::import("std::sync", "Arc");
Ok(quote! {
#[derive(Debug, Clone)]
pub struct $(t.name.pipe(|s| format_name(s))) {
pub proc: $arc<$child>,
pub selection: $selection,
@@ -86,7 +86,7 @@ pub fn render_optional_field_args(
}
quote! {
$(a.description.pipe(|d| format_struct_comment(d)))
#[builder(setter(into, strip_option))]
#[builder(setter(into, strip_option), default)]
pub $(format_struct_name(&a.name)): Option<$(type_)>,
}
});

View File

@@ -11,6 +11,18 @@ 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())
}
}
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())
}
}
})
}

View File

@@ -5,12 +5,79 @@ All notable changes to this project will be documented in this file.
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.4 (2023-02-20)
## v0.2.8 (2023-03-10)
### New Features
- <csr-id-41b20b6268db9d8defe333694e4d3ec019d7c923/> bump version
- <csr-id-5f9b3a19c0ab6988bc335b020052074f3f101305/> set internal warnings as errors
- <csr-id-f9e7af931d94fbedacf74f5da9a2f71b1992324b/> introduce tests again
### Bug Fixes
- <csr-id-8385aa8a15ff7b45fecc3462c482b998118c14eb/> remove blocking
- <csr-id-921e61b5e248013cb5fbf4f1bad3eef5a2673145/> remove blocking
- <csr-id-ecca036bc644fee93fbcb69bf6da9f29169e473e/> fix builder pattern to actually work with default values
In previous versions the builder pattern required all values to be set.
This has not been fixed, so that default values are allowed.
### Commit Statistics
<csr-read-only-do-not-edit/>
- 4 commits contributed to the release over the course of 13 calendar days.
- 13 days passed between releases.
- 4 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- bump version ([`41b20b6`](https://github.com/kjuulh/dagger-rs/commit/41b20b6268db9d8defe333694e4d3ec019d7c923))
- set internal warnings as errors ([`5f9b3a1`](https://github.com/kjuulh/dagger-rs/commit/5f9b3a19c0ab6988bc335b020052074f3f101305))
- introduce tests again ([`f9e7af9`](https://github.com/kjuulh/dagger-rs/commit/f9e7af931d94fbedacf74f5da9a2f71b1992324b))
- fix builder pattern to actually work with default values ([`ecca036`](https://github.com/kjuulh/dagger-rs/commit/ecca036bc644fee93fbcb69bf6da9f29169e473e))
</details>
## v0.2.7 (2023-02-24)
### New Features
- <csr-id-3e8ca8d86eafdc1f9d5e8b69f14fb60509549e0f/> update to dagger-v0.3.13
### Commit Statistics
<csr-read-only-do-not-edit/>
- 2 commits contributed to the release.
- 4 days passed between releases.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.7, dagger-sdk v0.2.15 ([`6a9a560`](https://github.com/kjuulh/dagger-rs/commit/6a9a560cdca097abf23371d44599a2f1b726ae7f))
- update to dagger-v0.3.13 ([`3e8ca8d`](https://github.com/kjuulh/dagger-rs/commit/3e8ca8d86eafdc1f9d5e8b69f14fb60509549e0f))
</details>
## v0.2.6 (2023-02-20)
<csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/>
### Chore
- <csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/> ran clippy
### Bug Fixes
- <csr-id-8dfecf976c5537cc2c03881de2b2fd2b2508683a/> cli session keep session alive
### Commit Statistics
@@ -27,6 +94,59 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.6, dagger-codegen v0.2.7, dagger-sdk v0.2.12 ([`7179f8b`](https://github.com/kjuulh/dagger-rs/commit/7179f8b598ef04e62925e39d3f55740253c01686))
- ran clippy ([`1f77d90`](https://github.com/kjuulh/dagger-rs/commit/1f77d90c0f0ac832a181b2322350ea395612986c))
- cli session keep session alive ([`8dfecf9`](https://github.com/kjuulh/dagger-rs/commit/8dfecf976c5537cc2c03881de2b2fd2b2508683a))
</details>
## v0.2.5 (2023-02-20)
### Bug Fixes
- <csr-id-a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de/> race condition in process
### Commit Statistics
<csr-read-only-do-not-edit/>
- 2 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.5, dagger-sdk v0.2.12, dagger-codegen v0.2.7 ([`1725c51`](https://github.com/kjuulh/dagger-rs/commit/1725c5188e8a81069ec4a4de569484c921a94927))
- race condition in process ([`a13a2a9`](https://github.com/kjuulh/dagger-rs/commit/a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de))
</details>
## v0.2.4 (2023-02-20)
### Bug Fixes
- <csr-id-8385aa8a15ff7b45fecc3462c482b998118c14eb/> remove blocking
- <csr-id-921e61b5e248013cb5fbf4f1bad3eef5a2673145/> remove blocking
### Commit Statistics
<csr-read-only-do-not-edit/>
- 4 commits contributed to the release.
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`f869e57`](https://github.com/kjuulh/dagger-rs/commit/f869e574dd788cd60e5b1b5d502bec68e300694c))
- remove blocking ([`921e61b`](https://github.com/kjuulh/dagger-rs/commit/921e61b5e248013cb5fbf4f1bad3eef5a2673145))
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`17ec62a`](https://github.com/kjuulh/dagger-rs/commit/17ec62a5d58232ff57391523b9851fb7b07d02ab))
- remove blocking ([`8385aa8`](https://github.com/kjuulh/dagger-rs/commit/8385aa8a15ff7b45fecc3462c482b998118c14eb))

View File

@@ -1,29 +1,30 @@
[package]
name = "dagger-core"
version = "0.2.4"
version = "0.2.8"
edition = "2021"
readme = "README.md"
license-file = "LICENSE.MIT"
description = "dagger sdk core library"
repository = "https://github.com/kjuulh/dagger-rs"
repository = "https://github.com/kjuulh/dagger-sdk"
publish = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
clap = "4.1.6"
eyre = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
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,10 +1,6 @@
use std::{
fs::canonicalize,
io::{BufRead, BufReader},
path::PathBuf,
process::{Child, Stdio},
sync::Arc,
};
use std::{fs::canonicalize, path::PathBuf, process::Stdio, sync::Arc};
use tokio::io::AsyncBufReadExt;
use crate::{config::Config, connect_params::ConnectParams};
@@ -24,7 +20,7 @@ impl CliSession {
&self,
config: &Config,
cli_path: &PathBuf,
) -> eyre::Result<(ConnectParams, Child)> {
) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
self.inner.connect(config, cli_path).await
}
}
@@ -37,13 +33,13 @@ impl InnerCliSession {
&self,
config: &Config,
cli_path: &PathBuf,
) -> eyre::Result<(ConnectParams, Child)> {
) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
let proc = self.start(config, cli_path)?;
let params = self.get_conn(proc).await?;
let params = self.get_conn(proc, config).await?;
Ok(params)
}
fn start(&self, config: &Config, cli_path: &PathBuf) -> eyre::Result<std::process::Child> {
fn start(&self, config: &Config, cli_path: &PathBuf) -> eyre::Result<tokio::process::Child> {
let mut args: Vec<String> = vec!["session".into()];
if let Some(workspace) = &config.workdir_path {
let abs_path = canonicalize(workspace)?;
@@ -54,7 +50,7 @@ impl InnerCliSession {
args.extend(["--project".into(), abs_path.to_string_lossy().to_string()])
}
let proc = std::process::Command::new(
let proc = tokio::process::Command::new(
cli_path
.to_str()
.ok_or(eyre::anyhow!("could not get string from path"))?,
@@ -72,8 +68,9 @@ impl InnerCliSession {
async fn get_conn(
&self,
mut proc: std::process::Child,
) -> eyre::Result<(ConnectParams, std::process::Child)> {
mut proc: tokio::process::Child,
config: &Config,
) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
let stdout = proc
.stdout
.take()
@@ -86,30 +83,33 @@ impl InnerCliSession {
let (sender, mut receiver) = tokio::sync::mpsc::channel(1);
let logger = config.logger.as_ref().map(|p| p.clone());
tokio::spawn(async move {
let stdout_bufr = BufReader::new(stdout);
for line in stdout_bufr.lines() {
let out = line.as_ref().unwrap();
if let Ok(conn) = serde_json::from_str::<ConnectParams>(&out) {
let mut stdout_bufr = tokio::io::BufReader::new(stdout).lines();
while let Ok(Some(line)) = stdout_bufr.next_line().await {
if let Ok(conn) = serde_json::from_str::<ConnectParams>(&line) {
sender.send(conn).await.unwrap();
}
if let Ok(line) = line {
println!("dagger: {}", line);
if let Some(logger) = &logger {
logger.stdout(&line).unwrap();
}
}
});
let logger = config.logger.as_ref().map(|p| p.clone());
tokio::spawn(async move {
let stderr_bufr = BufReader::new(stderr);
for line in stderr_bufr.lines() {
if let Ok(line) = line {
println!("dagger: {}", line);
let mut stderr_bufr = tokio::io::BufReader::new(stderr).lines();
while let Ok(Some(line)) = stderr_bufr.next_line().await {
if let Some(logger) = &logger {
logger.stdout(&line).unwrap();
}
//panic!("could not start dagger session: {}", out)
}
});
let conn = receiver.recv().await.ok_or(eyre::anyhow!("could not receive ok signal from dagger-engine"))?;
let conn = receiver.recv().await.ok_or(eyre::anyhow!(
"could not receive ok signal from dagger-engine"
))?;
Ok((conn, proc))
}

View File

@@ -1,15 +1,18 @@
use std::path::PathBuf;
use crate::logger::DynLogger;
pub struct Config {
pub workdir_path: Option<PathBuf>,
pub config_path: Option<PathBuf>,
pub timeout_ms: u64,
pub execute_timeout_ms: Option<u64>,
pub logger: Option<DynLogger>,
}
impl Default for Config {
fn default() -> Self {
Self::new(None, None, None, None)
Self::new(None, None, None, None, None)
}
}
@@ -19,12 +22,14 @@ impl Config {
config_path: Option<PathBuf>,
timeout_ms: Option<u64>,
execute_timeout_ms: Option<u64>,
logger: Option<DynLogger>,
) -> Self {
Self {
workdir_path,
config_path,
timeout_ms: timeout_ms.unwrap_or(10 * 1000),
execute_timeout_ms,
logger,
}
}
}

View File

@@ -1,6 +1,6 @@
use std::{
fs::File,
io::{copy, Read, Write},
io::{copy, Write},
os::unix::prelude::PermissionsExt,
path::PathBuf,
};
@@ -27,6 +27,7 @@ impl Platform {
let normalize_arch = match arch.as_str() {
"x86_64" => "amd64",
"aarch" => "arm64",
"aarch64" => "arm64",
arch => arch,
};
@@ -129,7 +130,8 @@ impl Downloader {
if !cli_bin_path.exists() {
cli_bin_path = self
.download(cli_bin_path).await
.download(cli_bin_path)
.await
.context("failed to download CLI from archive")?;
}
@@ -137,6 +139,11 @@ impl Downloader {
if let Ok(entry) = file {
let path = entry.path();
if path != cli_bin_path {
tracing::debug!(
path = path.display().to_string(),
cli_bin_path = cli_bin_path.display().to_string(),
"deleting existing dagger-engine"
);
std::fs::remove_file(path)?;
}
}
@@ -199,8 +206,6 @@ impl Downloader {
hasher.update(&bytes);
let res = hasher.finalize();
println!("{}", hex::encode(&res));
if archive_url.ends_with(".zip") {
// TODO: Nothing for now
todo!()
@@ -219,8 +224,6 @@ impl Downloader {
let mut entry = entry?;
let path = entry.path()?;
println!("path: {:?}", path);
if path.ends_with("dagger") {
copy(&mut entry, output)?;
@@ -238,7 +241,11 @@ mod test {
#[tokio::test]
async fn download() {
let cli_path = Downloader::new("0.3.10".into()).unwrap().get_cli().await.unwrap();
let cli_path = Downloader::new("0.3.10".into())
.unwrap()
.get_cli()
.await
.unwrap();
assert_eq!(
Some("dagger-0.3.10"),

View File

@@ -1,5 +1,4 @@
use std::process::Child;
use crate::DAGGER_ENGINE_VERSION;
use crate::{
cli_session::CliSession, config::Config, connect_params::ConnectParams, downloader::Downloader,
};
@@ -11,38 +10,23 @@ impl Engine {
Self {}
}
async fn from_cli(&self, cfg: &Config) -> eyre::Result<(ConnectParams, Child)> {
let cli = Downloader::new("0.3.12".into())?.get_cli().await?;
async fn from_cli(&self, cfg: &Config) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
let cli = Downloader::new(DAGGER_ENGINE_VERSION.into())?
.get_cli()
.await?;
let cli_session = CliSession::new();
Ok(cli_session.connect(cfg, &cli).await?)
}
pub async fn start(&self, cfg: &Config) -> eyre::Result<(ConnectParams, Child)> {
pub async fn start(
&self,
cfg: &Config,
) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
tracing::info!("starting dagger-engine");
// TODO: Add from existing session as well
self.from_cli(cfg).await
}
}
#[cfg(test)]
mod tests {
use crate::{config::Config, connect_params::ConnectParams};
use super::Engine;
// TODO: these tests potentially have a race condition
#[tokio::test]
async fn engine_can_start() {
let engine = Engine::new();
let params = engine.start(&Config::new(None, None, None, None)).await.unwrap();
assert_ne!(
params.0,
ConnectParams {
port: 123,
session_token: "123".into()
}
)
}
}

View File

@@ -241,6 +241,7 @@ pub struct SchemaTypes {
pub full_type: FullType,
}
#[allow(dead_code)]
#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SchemaDirectivesArgs {
@@ -257,6 +258,7 @@ pub struct SchemaDirectives {
pub args: Option<Vec<Option<SchemaDirectivesArgs>>>,
}
#[allow(dead_code)]
#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Schema {

View File

@@ -1,9 +1,14 @@
#![deny(warnings)]
pub const DAGGER_ENGINE_VERSION: &'static str = "0.4.0";
pub mod cli_session;
pub mod config;
pub mod connect_params;
pub mod downloader;
pub mod engine;
pub mod introspection;
pub mod logger;
pub mod schema;
pub mod session;

View File

@@ -0,0 +1,8 @@
use std::sync::Arc;
pub trait Logger {
fn stdout(&self, output: &str) -> eyre::Result<()>;
fn stderr(&self, output: &str) -> eyre::Result<()>;
}
pub type DynLogger = Arc<dyn Logger + Send + Sync>;

View File

@@ -2,7 +2,7 @@ use crate::introspection::IntrospectionResponse;
use crate::{config::Config, engine::Engine, session::Session};
pub async fn get_schema() -> eyre::Result<IntrospectionResponse> {
let cfg = Config::new(None, None, None, None);
let cfg = Config::default();
//TODO: Implement context for proc
let (conn, _proc) = Engine::new().start(&cfg).await?;
@@ -12,13 +12,3 @@ pub async fn get_schema() -> eyre::Result<IntrospectionResponse> {
Ok(schema)
}
#[cfg(test)]
mod tests {
use super::get_schema;
#[tokio::test]
async fn can_get_schema() {
let _ = get_schema().await.unwrap();
}
}

View File

@@ -6,13 +6,176 @@ 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.11 (2023-02-20)
<csr-id-803cfc4f8c4d72ab7d011be5523b3bfc6039de39/>
## v0.2.19 (2023-03-14)
### Chore
- <csr-id-803cfc4f8c4d72ab7d011be5523b3bfc6039de39/> ran clippy
- <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
- <csr-id-5593fce2e16e0aa97a2e6843f15d3bb1121048f5/> remove unused imports
- <csr-id-c025d1742482d701946c292dcf104421d3cade8e/> add support for String as well
- <csr-id-d7317e5cf34ee84a7b092357f5fbb15cd2bae2e3/> add public tuple field and into func
- <csr-id-44fa0240f8197f49fdf942b5c3d89079b59195d1/> update rust crate futures to 0.3.27
### Other
- <csr-id-f67928155f02076cbb41abd4010523879ff3caf1/> initial issue
### Refactor
- <csr-id-2cc0231c5f29993081f0f7e15e44cac95a7d6086/> remove export and instead use exitcode
- <csr-id-9ba01396cb44ee02cf7a16008e3f0bdae9f78754/> move issues to actual tests and refactor
- <csr-id-e9e35edb1cb67eee8cc033212aba3b1888def78f/> move issues to another folder
### Commit Statistics
<csr-read-only-do-not-edit/>
- 10 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
### Commit Details
<csr-read-only-do-not-edit/>
<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))
- move issues to actual tests and refactor ([`9ba0139`](https://github.com/kjuulh/dagger-rs/commit/9ba01396cb44ee02cf7a16008e3f0bdae9f78754))
- add support for String as well ([`c025d17`](https://github.com/kjuulh/dagger-rs/commit/c025d1742482d701946c292dcf104421d3cade8e))
- move issues to another folder ([`e9e35ed`](https://github.com/kjuulh/dagger-rs/commit/e9e35edb1cb67eee8cc033212aba3b1888def78f))
- add public tuple field and into func ([`d7317e5`](https://github.com/kjuulh/dagger-rs/commit/d7317e5cf34ee84a7b092357f5fbb15cd2bae2e3))
- initial issue ([`f679281`](https://github.com/kjuulh/dagger-rs/commit/f67928155f02076cbb41abd4010523879ff3caf1))
- update rust crate futures to 0.3.27 ([`44fa024`](https://github.com/kjuulh/dagger-rs/commit/44fa0240f8197f49fdf942b5c3d89079b59195d1))
</details>
## v0.2.16 (2023-03-10)
<csr-id-e642778d9028726dfb07217814e15ad1dd3b83f2/>
### Chore
- <csr-id-e642778d9028726dfb07217814e15ad1dd3b83f2/> fix tasks
### Documentation
- <csr-id-13b7805e7e6fcf47e0a1318adcc25b4ab773a3c9/> fix missing await in connect
### New Features
- <csr-id-7133bfae9508bc5977548e373c49342a1248d6e4/> with dagger-engine v.0.4.0
- <csr-id-4381af029521c2cbac9325278d261db79a994657/> add tests to sdk
- <csr-id-5f9b3a19c0ab6988bc335b020052074f3f101305/> set internal warnings as errors
### Bug Fixes
- <csr-id-ecca036bc644fee93fbcb69bf6da9f29169e473e/> fix builder pattern to actually work with default values
In previous versions the builder pattern required all values to be set.
This has not been fixed, so that default values are allowed.
### Commit Statistics
<csr-read-only-do-not-edit/>
- 7 commits contributed to the release over the course of 13 calendar days.
- 13 days passed between releases.
- 6 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.8, dagger-sdk v0.2.16 ([`f390eac`](https://github.com/kjuulh/dagger-rs/commit/f390eac29f1d041d18d2207a5aa0a8d993aab68c))
- fix tasks ([`e642778`](https://github.com/kjuulh/dagger-rs/commit/e642778d9028726dfb07217814e15ad1dd3b83f2))
- with dagger-engine v.0.4.0 ([`7133bfa`](https://github.com/kjuulh/dagger-rs/commit/7133bfae9508bc5977548e373c49342a1248d6e4))
- fix missing await in connect ([`13b7805`](https://github.com/kjuulh/dagger-rs/commit/13b7805e7e6fcf47e0a1318adcc25b4ab773a3c9))
- add tests to sdk ([`4381af0`](https://github.com/kjuulh/dagger-rs/commit/4381af029521c2cbac9325278d261db79a994657))
- set internal warnings as errors ([`5f9b3a1`](https://github.com/kjuulh/dagger-rs/commit/5f9b3a19c0ab6988bc335b020052074f3f101305))
- fix builder pattern to actually work with default values ([`ecca036`](https://github.com/kjuulh/dagger-rs/commit/ecca036bc644fee93fbcb69bf6da9f29169e473e))
</details>
## v0.2.15 (2023-02-24)
### New Features
- <csr-id-3e8ca8d86eafdc1f9d5e8b69f14fb60509549e0f/> update to dagger-v0.3.13
### Bug Fixes
- <csr-id-e578b0e371e13bc30ada793b7cd6ebe75ba83a07/> set deserialize on enums as well
### Commit Statistics
<csr-read-only-do-not-edit/>
- 3 commits contributed to the release.
- 2 days passed between releases.
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.7, dagger-sdk v0.2.15 ([`6a9a560`](https://github.com/kjuulh/dagger-rs/commit/6a9a560cdca097abf23371d44599a2f1b726ae7f))
- set deserialize on enums as well ([`e578b0e`](https://github.com/kjuulh/dagger-rs/commit/e578b0e371e13bc30ada793b7cd6ebe75ba83a07))
- update to dagger-v0.3.13 ([`3e8ca8d`](https://github.com/kjuulh/dagger-rs/commit/3e8ca8d86eafdc1f9d5e8b69f14fb60509549e0f))
</details>
## v0.2.14 (2023-02-22)
<csr-id-e331ca003546f4ebe00f33b65c3b45c6b0586514/>
### Chore
- <csr-id-e331ca003546f4ebe00f33b65c3b45c6b0586514/> fix whitespace
### Commit Statistics
@@ -29,6 +192,89 @@ and this project adheres to
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-sdk v0.2.14 ([`88b055c`](https://github.com/kjuulh/dagger-rs/commit/88b055cb47d3d474e2c37d8fa8259df5faad9da5))
- fix whitespace ([`e331ca0`](https://github.com/kjuulh/dagger-rs/commit/e331ca003546f4ebe00f33b65c3b45c6b0586514))
</details>
## v0.2.13 (2023-02-22)
<csr-id-7c3654d276bb5f66e692a210cb60cdf46b19e226/>
<csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/>
### Chore
- <csr-id-7c3654d276bb5f66e692a210cb60cdf46b19e226/> ran clippy
- <csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/> ran clippy
### New Features
- <csr-id-266ad32dff4c8957c7cdd291f9ef6f8a8c1d055c/> with clone
### Bug Fixes
- <csr-id-a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de/> race condition in process
### Commit Statistics
<csr-read-only-do-not-edit/>
- 7 commits contributed to the release over the course of 2 calendar days.
- 2 days passed between releases.
- 4 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-codegen v0.2.8, dagger-sdk v0.2.13 ([`456f483`](https://github.com/kjuulh/dagger-rs/commit/456f48389b5514d7f743a600a7732fb02dd87418))
- ran clippy ([`7c3654d`](https://github.com/kjuulh/dagger-rs/commit/7c3654d276bb5f66e692a210cb60cdf46b19e226))
- with clone ([`266ad32`](https://github.com/kjuulh/dagger-rs/commit/266ad32dff4c8957c7cdd291f9ef6f8a8c1d055c))
- Release dagger-core v0.2.6, dagger-codegen v0.2.7, dagger-sdk v0.2.12 ([`7179f8b`](https://github.com/kjuulh/dagger-rs/commit/7179f8b598ef04e62925e39d3f55740253c01686))
- ran clippy ([`1f77d90`](https://github.com/kjuulh/dagger-rs/commit/1f77d90c0f0ac832a181b2322350ea395612986c))
- Release dagger-core v0.2.5, dagger-sdk v0.2.12, dagger-codegen v0.2.7 ([`1725c51`](https://github.com/kjuulh/dagger-rs/commit/1725c5188e8a81069ec4a4de569484c921a94927))
- race condition in process ([`a13a2a9`](https://github.com/kjuulh/dagger-rs/commit/a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de))
</details>
## v0.2.12 (2023-02-20)
<csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/>
### Chore
- <csr-id-1f77d90c0f0ac832a181b2322350ea395612986c/> ran clippy
### Bug Fixes
- <csr-id-a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de/> race condition in process
## v0.2.11 (2023-02-20)
<csr-id-803cfc4f8c4d72ab7d011be5523b3bfc6039de39/>
### Chore
- <csr-id-803cfc4f8c4d72ab7d011be5523b3bfc6039de39/> ran clippy
### Commit Statistics
<csr-read-only-do-not-edit/>
- 3 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`f869e57`](https://github.com/kjuulh/dagger-rs/commit/f869e574dd788cd60e5b1b5d502bec68e300694c))
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`17ec62a`](https://github.com/kjuulh/dagger-rs/commit/17ec62a5d58232ff57391523b9851fb7b07d02ab))
- ran clippy ([`803cfc4`](https://github.com/kjuulh/dagger-rs/commit/803cfc4f8c4d72ab7d011be5523b3bfc6039de39))
</details>

View File

@@ -1,28 +1,32 @@
[package]
name = "dagger-sdk"
version = "0.2.11"
version = "0.2.19"
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"
repository = "https://github.com/kjuulh/dagger-sdk"
publish = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dagger-core = { path = "../dagger-core", version = "^0.2.4" }
dagger-core = { workspace = true }
eyre = { workspace = true }
tokio = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
tracing.workspace = true
tracing-subscriber.workspace = true
base64 = "0.21.0"
eyre = "0.6.8"
futures = "0.3.26"
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]
pretty_assertions = "1.3.0"
rand = "0.8.5"
genco = "0.17.3"
tracing-test = "0.2.4"

View File

@@ -27,7 +27,7 @@ cargo add dagger-sdk
```rust
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect()?;
let client = dagger_sdk::connect().await?;
let version = client
.container()
@@ -46,9 +46,3 @@ And run it like a normal application:
```bash
cargo run
```
### Disclaimer
You are free to use something else than `tokio`, I haven't tested it with
anything else, but it should work with any other runtime. We don't rely on it
specifically. That might change in the future though.

View File

@@ -35,7 +35,8 @@ async fn main() -> eyre::Result<()> {
.container()
.from("nginx")
.with_directory("/usr/share/nginx/html", build_dir.id().await?)
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>())).await?;
.publish(format!("ttl.sh/hello-dagger-sdk-{}:1h", rng.gen::<u64>()))
.await?;
println!("published image to: {}", ref_);

View File

@@ -13,7 +13,8 @@ async fn main() -> eyre::Result<()> {
let ref_ = client
.container()
.build(context_dir.id().await?)
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>())).await?;
.publish(format!("ttl.sh/hello-dagger-sdk-{}:1h", rng.gen::<u64>()))
.await?;
println!("published image to: {}", ref_);

View File

@@ -6,7 +6,8 @@ async fn main() -> eyre::Result<()> {
.container()
.from("golang:1.19")
.with_exec(vec!["go", "version"])
.stdout().await?;
.stdout()
.await?;
println!("Hello from Dagger and {}", version.trim());

View File

@@ -0,0 +1,25 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
build-*

View File

@@ -0,0 +1,17 @@
# React Build
This is based on the [Getting Started guide for Nodejs](https://docs.dagger.io/sdk/nodejs/783645/get-started#step-5-test-against-multiple-nodejs-versions)
A simple react app is created with `create-react-app` which is built and tested by `build.js` or `build.ts`.
Run:
`npm install`
and then:
`node --loader ts-node/esm ./build.ts`
or
`node ./build.js`

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,48 @@
{
"name": "react-build",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.6",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"ts-node": "^10.9.1",
"typescript": "^4.9.3",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"type": "module",
"devDependencies": {
"@dagger.io/dagger": "^0.3.2"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View File

@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View File

@@ -0,0 +1,38 @@
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

View File

@@ -0,0 +1,9 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

View File

@@ -0,0 +1,26 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;

View File

@@ -0,0 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}

View File

@@ -0,0 +1,19 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -0,0 +1 @@
/// <reference types="react-scripts" />

View File

@@ -0,0 +1,15 @@
import { ReportHandler } from 'web-vitals';
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;

View File

@@ -0,0 +1,5 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';

View File

@@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}

View File

@@ -0,0 +1,49 @@
use std::sync::Arc;
use dagger_sdk::logging::TracingLogger;
use dagger_sdk::HostDirectoryOpts;
#[tokio::main]
async fn main() -> eyre::Result<()> {
dagger_sdk::logging::default_logging()?;
let client = dagger_sdk::connect_opts(dagger_sdk::Config {
workdir_path: None,
config_path: None,
timeout_ms: 1000,
execute_timeout_ms: None,
logger: Some(Arc::new(TracingLogger::default())),
})
.await?;
let host_source_dir = client.host().directory_opts(
"examples/build-the-application/app",
HostDirectoryOpts {
exclude: Some(vec!["node_modules".into(), "ci/".into()]),
include: None,
},
);
let source = client
.container()
.from("node:16")
.with_mounted_directory("/src", host_source_dir.id().await?);
let runner = source
.with_workdir("/src")
.with_exec(vec!["npm", "install"]);
let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"]);
let build_dir = test
.with_exec(vec!["npm", "run", "build"])
.directory("./build");
let _ = build_dir.export("./build");
let entries = build_dir.entries().await;
println!("build dir contents: \n {:?}", entries);
Ok(())
}

View File

@@ -34,7 +34,7 @@ async fn main() -> eyre::Result<()> {
.container()
.from("nginx")
.with_directory("/usr/share/nginx/html", build_dir.id().await?)
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()))
.publish(format!("ttl.sh/hello-dagger-sdk-{}:1h", rng.gen::<u64>()))
.await?;
println!("published image to: {}", ref_);

View File

@@ -39,7 +39,8 @@ async fn main() -> eyre::Result<()> {
"/usr/share/nginx/html",
client.host().directory(output).id().await?,
)
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>())).await?;
.publish(format!("ttl.sh/hello-dagger-sdk-{}:1h", rng.gen::<u64>()))
.await?;
println!("published image to: {}", ref_);

View File

@@ -23,7 +23,8 @@ async fn main() -> eyre::Result<()> {
let out = runner
.with_exec(vec!["npm", "test", "--", "--watchAll=false"])
.stderr().await?;
.stderr()
.await?;
println!("{}", out);

View File

@@ -3,18 +3,25 @@ use std::sync::Arc;
use base64::engine::general_purpose;
use base64::Engine;
use gql_client::ClientConfig;
use dagger_core::config::Config;
use dagger_core::connect_params::ConnectParams;
use dagger_core::engine::Engine as DaggerEngine;
use gql_client::ClientConfig;
use crate::gen::Query;
use crate::logging::StdLogger;
use crate::querybuilder::query;
pub type DaggerConn = Arc<Query>;
pub async fn connect() -> eyre::Result<DaggerConn> {
let cfg = Config::default();
let cfg = Config::new(None, None, None, None, Some(Arc::new(StdLogger::default())));
connect_opts(cfg).await
}
pub async fn connect_opts(cfg: Config) -> eyre::Result<DaggerConn> {
let (conn, proc) = DaggerEngine::new().start(&cfg).await?;
Ok(Arc::new(Query {

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,10 @@
#![deny(warnings)]
mod client;
mod gen;
pub mod logging;
mod querybuilder;
pub use client::*;
pub use dagger_core::config::Config;
pub use gen::*;

View File

@@ -0,0 +1,81 @@
use dagger_core::logger::{DynLogger, Logger};
use tracing::Level;
pub fn default_logging() -> eyre::Result<()> {
tracing_subscriber::fmt().with_max_level(Level::INFO).init();
Ok(())
}
pub struct StdLogger {}
impl Default for StdLogger {
fn default() -> Self {
Self {}
}
}
impl Logger for StdLogger {
fn stdout(&self, output: &str) -> eyre::Result<()> {
println!("{}", output);
Ok(())
}
fn stderr(&self, output: &str) -> eyre::Result<()> {
eprintln!("{}", output);
Ok(())
}
}
pub struct TracingLogger {}
impl Default for TracingLogger {
fn default() -> Self {
Self {}
}
}
impl Logger for TracingLogger {
fn stdout(&self, output: &str) -> eyre::Result<()> {
tracing::info!(output = output, "dagger-sdk");
Ok(())
}
fn stderr(&self, output: &str) -> eyre::Result<()> {
tracing::warn!(output = output, "dagger-sdk");
Ok(())
}
}
pub struct AggregateLogger {
pub loggers: Vec<DynLogger>,
}
impl Default for AggregateLogger {
fn default() -> Self {
Self {
loggers: Vec::new(),
}
}
}
impl Logger for AggregateLogger {
fn stdout(&self, output: &str) -> eyre::Result<()> {
for logger in &self.loggers {
logger.stdout(output).unwrap()
}
Ok(())
}
fn stderr(&self, output: &str) -> eyre::Result<()> {
for logger in &self.loggers {
logger.stderr(output).unwrap()
}
Ok(())
}
}

View File

@@ -68,6 +68,29 @@ 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();
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()];
@@ -76,7 +99,7 @@ impl Selection {
if let Some(args) = sel.args {
let actualargs = args
.iter()
.map(|(name, arg)| format!("{name}:{arg}"))
.map(|(name, arg)| format!("{name}:{}", arg.as_str()))
.collect::<Vec<_>>();
query = query.add(&format!("({})", actualargs.join(", ")));
@@ -99,6 +122,8 @@ impl Selection {
{
let query = self.build()?;
tracing::trace!(query = query.as_str(), "dagger-query");
let resp: Option<serde_json::Value> = match gql_client.query(&query).await {
Ok(r) => r,
Err(e) => eyre::bail!(e),

View 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(())
}

View File

@@ -0,0 +1,29 @@
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

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

View File

@@ -1,4 +1,7 @@
mod issues;
use dagger_sdk::{connect, ContainerExecOptsBuilder};
use pretty_assertions::assert_eq;
#[tokio::test]
async fn test_example_container() {
@@ -19,3 +22,99 @@ async fn test_example_container() {
assert_eq!(out, "3.16.2\n".to_string())
}
#[tokio::test]
async fn test_directory() {
let c = connect().await.unwrap();
let contents = c
.directory()
.with_new_file("/hello.txt", "world")
.file("/hello.txt")
.contents()
.await
.unwrap();
assert_eq!("world", contents)
}
#[tokio::test]
async fn test_git() {
let c = connect().await.unwrap();
let tree = c.git("github.com/dagger/dagger").branch("main").tree();
let _ = tree
.entries()
.await
.unwrap()
.iter()
.find(|f| f.as_str() == "README.md")
.unwrap();
let readme_file = tree.file("README.md");
let readme = readme_file.contents().await.unwrap();
assert_eq!(true, readme.find("Dagger").is_some());
let readme_id = readme_file.id().await.unwrap();
let other_readme = c.file(readme_id).contents().await.unwrap();
assert_eq!(readme, other_readme);
}
#[tokio::test]
async fn test_container() {
let client = connect().await.unwrap();
let alpine = client.container().from("alpine:3.16.2");
let contents = alpine
.fs()
.file("/etc/alpine-release")
.contents()
.await
.unwrap();
assert_eq!(contents, "3.16.2\n".to_string());
let out = alpine
.exec_opts(
ContainerExecOptsBuilder::default()
.args(vec!["cat", "/etc/alpine-release"])
.build()
.unwrap(),
)
.stdout()
.await
.unwrap();
assert_eq!(out, "3.16.2\n".to_string());
let id = alpine.id().await.unwrap();
let contents = client
.container_opts(dagger_sdk::QueryContainerOpts {
id: Some(id),
platform: None,
})
.fs()
.file("/etc/alpine-release")
.contents()
.await
.unwrap();
assert_eq!(contents, "3.16.2\n".to_string());
}
#[tokio::test]
async fn test_err_message() {
let client = connect().await.unwrap();
let alpine = client.container().from("fake.invalid:latest").id().await;
assert_eq!(alpine.is_err(), true);
let err = alpine.expect_err("Tests expect err");
let error_msg = r#"
GQLClient Error: Look at json field for more details
Message: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
"#;
assert_eq!(err.to_string().as_str(), error_msg);
}