Compare commits

..

20 Commits

Author SHA1 Message Date
665164464d chore: add dependencies 2023-03-19 01:09:46 +01:00
7e6853ed63 feat: with base 2023-03-19 01:03:56 +01:00
0f816b5e29 chore(WIP): working on fixing macos cross compile 2023-03-19 01:03:56 +01:00
46208d5681 fix: setup with colima instead 2023-03-19 01:03:56 +01:00
1570e01ff9 fix: longer docker timemout 2023-03-19 01:03:56 +01:00
7d3fc5e3e2 fix: setup docker 2023-03-19 01:03:56 +01:00
c56370182f fix: with target 2023-03-19 01:03:56 +01:00
6858ee74cd fix: with proper '' 2023-03-19 01:03:55 +01:00
84bcf10809 fix: permissions for macos 2023-03-19 01:03:55 +01:00
59b42fc273 feat: fix macos 2023-03-19 01:03:55 +01:00
1e10149522 feat: reorder tasks 2023-03-19 01:03:55 +01:00
cb66d99088 feat: with docker buildx 2023-03-19 01:03:55 +01:00
2d171249d9 feat: test other way around 2023-03-19 01:03:55 +01:00
8ad390f813 fix: with proper disable of windows 2023-03-19 01:03:55 +01:00
6dd6a47131 fix: without windows support for now
'see #47'
2023-03-19 01:03:55 +01:00
e194a01893 fix: native-tls-vendored 2023-03-19 01:03:54 +01:00
9599e6f484 feat: with multi platform ci 2023-03-19 01:03:54 +01:00
11d20935c6 feat: extract client (#48)
This extracts the client (strategy pattern), this is so that it is will be possible to test the actual querier, without hitting / requiring the dagger-engine running.
2023-03-19 00:01:24 +00:00
384294b390 feat: rename projects to point to github/kjuulh/dagger-sdk 2023-03-18 15:33:14 +01:00
79d931e908 feat: with loggers 2023-03-14 23:21:14 +01:00
25 changed files with 969 additions and 324 deletions

121
.github/workflows/ci-multiplatform.yml vendored Normal file
View File

@@ -0,0 +1,121 @@
name: ci-multi-platform
on:
pull_request:
push:
branches:
- main
schedule:
- cron: '00 01 * * *'
jobs:
test:
name: test
env:
# For some builds, we use cross to test on 32-bit and big-endian
# systems.
CARGO: cargo
# When CARGO is set to CROSS, this is set to `--target matrix.target`.
TARGET_FLAGS: ""
# When CARGO is set to CROSS, TARGET_DIR includes matrix.target.
TARGET_DIR: ./target
# Emit backtraces on panics.
RUST_BACKTRACE: 1
runs-on: ${{ matrix.os }}
strategy:
matrix:
build:
- pinned
- stable
- beta
- nightly
#- nightly-musl
#- nightly-32
#- nightly-mips
#- nightly-arm
#- macos
# - win-msvc
#- win-gnu
include:
- build: pinned
os: ubuntu-22.04
rust: 1.65.0
- build: stable
os: ubuntu-22.04
rust: stable
- build: beta
os: ubuntu-22.04
rust: beta
- build: nightly
os: ubuntu-22.04
rust: nightly
#- build: nightly-musl
# os: ubuntu-22.04
# rust: nightly
# target: x86_64-unknown-linux-musl
#- build: nightly-32
# os: ubuntu-22.04
# rust: nightly
# target: i686-unknown-linux-gnu
#- build: nightly-mips
# os: ubuntu-22.04
# rust: nightly
# target: mips64-unknown-linux-gnuabi64
#- build: nightly-arm
# os: ubuntu-22.04
# rust: nightly
# target: arm-unknown-linux-gnueabihf
#- build: macos
# os: macos-12
# rust: nightly
#- build: win-msvc
# os: windows-2022
# rust: nightly
#- build: win-gnu
# os: windows-2022
# rust: nightly-x86_64-gnu
steps:
- name: Checkout repository
uses: actions/checkout@v3
#- name: Install packages (Ubuntu)
# if: matrix.os == 'ubuntu-22.04'
# run: |
# ci/ubuntu-install-packages
- name: Install packages (macOS)
if: matrix.os == 'macos-12'
run: |
ci/scripts/macos-install-packages
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.0.0
- uses: actions-rs/toolchain@v1
if: matrix.target == ''
with:
toolchain: ${{ matrix.rust }}
- uses: actions-rs/toolchain@v1
if: matrix.target != ''
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
use-cross: true
- uses: actions-rs/cargo@v1
if: matrix.target != ''
with:
use-cross: true
command: build
args: --workspace --verbose --target ${{ matrix.target }}
- uses: actions-rs/cargo@v1
if: matrix.target == ''
with:
command: build
args: --workspace --verbose
- uses: actions-rs/cargo@v1
if: matrix.target != ''
with:
use-cross: true
command: test
args: --all --verbose --target ${{ matrix.target }}
- uses: actions-rs/cargo@v1
if: matrix.target == ''
with:
command: test
args: --all --verbose

281
Cargo.lock generated
View File

@@ -24,16 +24,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e"
[[package]] [[package]]
name = "async-compression" name = "async-trait"
version = "0.3.15" version = "0.1.67"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "942c7cd7ae39e91bde4820d74132e9862e62c2f386c3aa90ccf55949f5bad63a" checksum = "86ea188f25f0255d8f92797797c97ebf5631fa88178beb1a46fdf5622c9a00e4"
dependencies = [ dependencies = [
"flate2", "proc-macro2",
"futures-core", "quote",
"memchr", "syn 2.0.0",
"pin-project-lite",
"tokio",
] ]
[[package]] [[package]]
@@ -121,9 +119,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.1.8" version = "4.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" checksum = "ce38afc168d8665cfc75c7b1dd9672e50716a137f433f070991619744a67342a"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"clap_lex", "clap_lex",
@@ -134,9 +132,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_lex" name = "clap_lex"
version = "0.3.2" version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09" checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646"
dependencies = [ dependencies = [
"os_str_bytes", "os_str_bytes",
] ]
@@ -241,7 +239,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096"
dependencies = [ dependencies = [
"quote", "quote",
"syn", "syn 1.0.109",
]
[[package]]
name = "dagger-bootstrap"
version = "0.2.10"
dependencies = [
"clap",
"color-eyre",
"dagger-codegen",
"dagger-core",
"dirs",
"eyre",
"graphql_client",
"hex",
"hex-literal",
"platform-info",
"reqwest",
"serde",
"serde_json",
"sha2",
"tar",
"tempfile",
"tokio",
] ]
[[package]] [[package]]
@@ -262,10 +283,12 @@ dependencies = [
name = "dagger-core" name = "dagger-core"
version = "0.2.8" version = "0.2.8"
dependencies = [ dependencies = [
"async-trait",
"base64",
"dirs", "dirs",
"eyre", "eyre",
"flate2", "flate2",
"graphql-introspection-query", "gql_client",
"graphql_client", "graphql_client",
"hex", "hex",
"hex-literal", "hex-literal",
@@ -281,42 +304,15 @@ dependencies = [
"tracing-subscriber", "tracing-subscriber",
] ]
[[package]]
name = "dagger-rs"
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]] [[package]]
name = "dagger-sdk" name = "dagger-sdk"
version = "0.2.19" version = "0.2.19"
dependencies = [ dependencies = [
"base64",
"dagger-core", "dagger-core",
"derive_builder", "derive_builder",
"eyre", "eyre",
"futures", "futures",
"genco", "genco",
"gql_client",
"pretty_assertions", "pretty_assertions",
"rand", "rand",
"serde", "serde",
@@ -348,7 +344,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"strsim", "strsim",
"syn", "syn 1.0.109",
] ]
[[package]] [[package]]
@@ -359,7 +355,7 @@ checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e"
dependencies = [ dependencies = [
"darling_core", "darling_core",
"quote", "quote",
"syn", "syn 1.0.109",
] ]
[[package]] [[package]]
@@ -380,7 +376,7 @@ dependencies = [
"darling", "darling",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 1.0.109",
] ]
[[package]] [[package]]
@@ -390,7 +386,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e" checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e"
dependencies = [ dependencies = [
"derive_builder_core", "derive_builder_core",
"syn", "syn 1.0.109",
] ]
[[package]] [[package]]
@@ -503,7 +499,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"libz-sys",
"miniz_oxide", "miniz_oxide",
] ]
@@ -593,7 +588,7 @@ checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 1.0.109",
] ]
[[package]] [[package]]
@@ -645,7 +640,7 @@ checksum = "c85fd34848b1f708e6344a4af6f7bfc05172ae20ce4b35c8e417efffb4f306aa"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 1.0.109",
] ]
[[package]] [[package]]
@@ -732,7 +727,7 @@ dependencies = [
"quote", "quote",
"serde", "serde",
"serde_json", "serde_json",
"syn", "syn 1.0.109",
] ]
[[package]] [[package]]
@@ -743,7 +738,7 @@ checksum = "d52fc9cde811f44b15ec0692b31e56a3067f6f431c5ace712f286e47c1dacc98"
dependencies = [ dependencies = [
"graphql_client_codegen", "graphql_client_codegen",
"proc-macro2", "proc-macro2",
"syn", "syn 1.0.109",
] ]
[[package]] [[package]]
@@ -862,6 +857,19 @@ dependencies = [
"want", "want",
] ]
[[package]]
name = "hyper-rustls"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c"
dependencies = [
"http",
"hyper",
"rustls",
"tokio",
"tokio-rustls",
]
[[package]] [[package]]
name = "hyper-tls" name = "hyper-tls"
version = "0.5.0" version = "0.5.0"
@@ -918,10 +926,11 @@ dependencies = [
[[package]] [[package]]
name = "io-lifetimes" name = "io-lifetimes"
version = "1.0.6" version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" checksum = "0dd6da19f25979c7270e70fa95ab371ec3b701cd0eefc47667a09785b3c59155"
dependencies = [ dependencies = [
"hermit-abi 0.3.1",
"libc", "libc",
"windows-sys 0.45.0", "windows-sys 0.45.0",
] ]
@@ -934,9 +943,9 @@ checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146"
[[package]] [[package]]
name = "is-terminal" name = "is-terminal"
version = "0.4.4" version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e"
dependencies = [ dependencies = [
"hermit-abi 0.3.1", "hermit-abi 0.3.1",
"io-lifetimes", "io-lifetimes",
@@ -980,17 +989,6 @@ version = "0.2.140"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
[[package]]
name = "libz-sys"
version = "1.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf"
dependencies = [
"cc",
"pkg-config",
"vcpkg",
]
[[package]] [[package]]
name = "linux-raw-sys" name = "linux-raw-sys"
version = "0.1.4" version = "0.1.4"
@@ -1113,9 +1111,9 @@ checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.45" version = "0.10.46"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" checksum = "fd2523381e46256e40930512c7fd25562b9eae4812cb52078f155e87217c9d1e"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if", "cfg-if",
@@ -1134,7 +1132,7 @@ checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 1.0.109",
] ]
[[package]] [[package]]
@@ -1145,9 +1143,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.9.80" version = "0.9.81"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" checksum = "176be2629957c157240f68f61f2d0053ad3a4ecfdd9ebf1e6521d18d9635cf67"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cc", "cc",
@@ -1362,7 +1360,6 @@ version = "0.11.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9"
dependencies = [ dependencies = [
"async-compression",
"base64", "base64",
"bytes", "bytes",
"encoding_rs", "encoding_rs",
@@ -1372,6 +1369,7 @@ dependencies = [
"http", "http",
"http-body", "http-body",
"hyper", "hyper",
"hyper-rustls",
"hyper-tls", "hyper-tls",
"ipnet", "ipnet",
"js-sys", "js-sys",
@@ -1381,11 +1379,14 @@ dependencies = [
"once_cell", "once_cell",
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
"rustls",
"rustls-pemfile",
"serde", "serde",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"tokio", "tokio",
"tokio-native-tls", "tokio-native-tls",
"tokio-rustls",
"tokio-util", "tokio-util",
"tower-service", "tower-service",
"url", "url",
@@ -1393,9 +1394,25 @@ dependencies = [
"wasm-bindgen-futures", "wasm-bindgen-futures",
"wasm-streams", "wasm-streams",
"web-sys", "web-sys",
"webpki-roots",
"winreg", "winreg",
] ]
[[package]]
name = "ring"
version = "0.16.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
dependencies = [
"cc",
"libc",
"once_cell",
"spin",
"untrusted",
"web-sys",
"winapi",
]
[[package]] [[package]]
name = "rustc-demangle" name = "rustc-demangle"
version = "0.1.21" version = "0.1.21"
@@ -1404,9 +1421,9 @@ checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.36.9" version = "0.36.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" checksum = "2fe885c3a125aa45213b68cc1472a49880cb5923dc23f522ad2791b882228778"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"errno", "errno",
@@ -1416,6 +1433,27 @@ dependencies = [
"windows-sys 0.45.0", "windows-sys 0.45.0",
] ]
[[package]]
name = "rustls"
version = "0.20.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f"
dependencies = [
"log",
"ring",
"sct",
"webpki",
]
[[package]]
name = "rustls-pemfile"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b"
dependencies = [
"base64",
]
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.13" version = "1.0.13"
@@ -1437,6 +1475,16 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "sct"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
dependencies = [
"ring",
"untrusted",
]
[[package]] [[package]]
name = "security-framework" name = "security-framework"
version = "2.8.2" version = "2.8.2"
@@ -1462,22 +1510,22 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.156" version = "1.0.157"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4" checksum = "707de5fcf5df2b5788fca98dd7eab490bc2fd9b7ef1404defc462833b83f25ca"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.156" version = "1.0.157"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" checksum = "78997f4555c22a7971214540c4a661291970619afd56de19f77e0de86296e1e5"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 2.0.0",
] ]
[[package]] [[package]]
@@ -1557,6 +1605,12 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "spin"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.10.0" version = "0.10.0"
@@ -1574,6 +1628,17 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "syn"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cff13bb1732bccfe3b246f3fdb09edfd51c01d6f5299b7ccd9457c2e4e37774"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]] [[package]]
name = "tar" name = "tar"
version = "0.4.38" version = "0.4.38"
@@ -1609,22 +1674,22 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.39" version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.39" version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 2.0.0",
] ]
[[package]] [[package]]
@@ -1680,7 +1745,7 @@ checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 1.0.109",
] ]
[[package]] [[package]]
@@ -1693,6 +1758,17 @@ dependencies = [
"tokio", "tokio",
] ]
[[package]]
name = "tokio-rustls"
version = "0.23.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59"
dependencies = [
"rustls",
"tokio",
"webpki",
]
[[package]] [[package]]
name = "tokio-util" name = "tokio-util"
version = "0.7.7" version = "0.7.7"
@@ -1734,7 +1810,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 1.0.109",
] ]
[[package]] [[package]]
@@ -1806,7 +1882,7 @@ checksum = "258bc1c4f8e2e73a977812ab339d503e6feeb92700f6d07a6de4d321522d5c08"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"quote", "quote",
"syn", "syn 1.0.109",
] ]
[[package]] [[package]]
@@ -1823,9 +1899,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]] [[package]]
name = "unicode-bidi" name = "unicode-bidi"
version = "0.3.11" version = "0.3.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" checksum = "7d502c968c6a838ead8e69b2ee18ec708802f99db92a0d156705ec9ef801993b"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
@@ -1857,6 +1933,12 @@ dependencies = [
"void", "void",
] ]
[[package]]
name = "untrusted"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]] [[package]]
name = "url" name = "url"
version = "2.3.1" version = "2.3.1"
@@ -1929,7 +2011,7 @@ dependencies = [
"once_cell", "once_cell",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 1.0.109",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@@ -1963,7 +2045,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 1.0.109",
"wasm-bindgen-backend", "wasm-bindgen-backend",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
@@ -1997,6 +2079,25 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "webpki"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
dependencies = [
"ring",
"untrusted",
]
[[package]]
name = "webpki-roots"
version = "0.22.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87"
dependencies = [
"webpki",
]
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"

View File

@@ -3,14 +3,14 @@ members = [
"crates/dagger-codegen", "crates/dagger-codegen",
"crates/dagger-sdk", "crates/dagger-sdk",
"crates/dagger-core", "crates/dagger-core",
"crates/dagger-rs", "crates/dagger-bootstrap",
"ci", "ci",
] ]
[workspace.dependencies] [workspace.dependencies]
dagger-codegen = { path = "crates/dagger-codegen", version = "^0.2.5" } dagger-codegen = { path = "crates/dagger-codegen", version = "^0.2.5" }
dagger-core = { path = "crates/dagger-core", version = "^0.2.8" } dagger-core = { path = "crates/dagger-core", version = "^0.2.8" }
dagger-rs = { path = "crates/dagger-rs", version = "^0.2.10" } dagger-bootstrap = { path = "crates/dagger-bootstrap", version = "^0.2.10" }
dagger-sdk = { path = "crates/dagger-sdk", version = "^0.2.19" } dagger-sdk = { path = "crates/dagger-sdk", version = "^0.2.19" }
eyre = "0.6.8" eyre = "0.6.8"

View File

@@ -8,7 +8,7 @@ command = "cargo"
args = [ args = [
"run", "run",
"-p", "-p",
"dagger-rs", "dagger-bootstrap",
"--", "--",
"generate", "generate",
"--output", "--output",

View File

@@ -0,0 +1,4 @@
#!/bin/sh
brew install docker
colima start

View File

@@ -90,7 +90,7 @@ async fn release(client: Arc<Query>, _subm: &clap::ArgMatches) -> Result<(), col
"--execute", "--execute",
"--allow-fully-generated-changelogs", "--allow-fully-generated-changelogs",
"--no-changelog-preview", "--no-changelog-preview",
"dagger-rs", "dagger-sdk",
"dagger-sdk", "dagger-sdk",
]); ]);
let exit = container.exit_code().await?; let exit = container.exit_code().await?;

View File

@@ -1,11 +1,11 @@
[package] [package]
name = "dagger-rs" name = "dagger-bootstrap"
version = "0.2.10" version = "0.2.10"
edition = "2021" edition = "2021"
readme = "README.md" readme = "README.md"
license-file = "LICENSE.MIT" license-file = "LICENSE.MIT"
description = "A dagger sdk for rust, written in rust" 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 publish = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -20,15 +20,20 @@ serde = { workspace = true }
serde_json = { workspace = true } serde_json = { workspace = true }
tokio = { workspace = true } tokio = { workspace = true }
reqwest = { version = "0.11.14", features = [
"stream",
"rustls",
"hyper-rustls",
"rustls-tls",
] }
clap = "4.1.6" clap = "4.1.6"
dirs = "4.0.0" dirs = "4.0.0"
flate2 = { version = "1.0.25", features = ["zlib"] } graphql_client = { version = "0.12.0", features = [
graphql-introspection-query = "0.2.0" "reqwest-rustls",
graphql_client = { version = "0.12.0", features = ["reqwest"] } ], default_features = false }
hex = "0.4.3" hex = "0.4.3"
hex-literal = "0.3.4" hex-literal = "0.3.4"
platform-info = "1.0.2" platform-info = "1.0.2"
reqwest = { version = "0.11.14", features = ["stream", "deflate"] }
sha2 = "0.10.6" sha2 = "0.10.6"
tar = "0.4.38" tar = "0.4.38"
tempfile = "3.3.0" tempfile = "3.3.0"

View File

@@ -5,7 +5,7 @@ edition = "2021"
readme = "README.md" readme = "README.md"
license-file = "LICENSE.MIT" license-file = "LICENSE.MIT"
description = "dagger sdk codegen library" description = "dagger sdk codegen library"
repository = "https://github.com/kjuulh/dagger-rs" repository = "https://github.com/kjuulh/dagger-sdk"
publish = true publish = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -247,7 +247,7 @@ fn render_execution(funcs: &CommonFunctions, field: &FullTypeFields) -> rust::To
return $(output_type) { return $(output_type) {
proc: self.proc.clone(), proc: self.proc.clone(),
selection: query, selection: query,
conn: self.conn.clone(), graphql_client: self.graphql_client.clone(),
} }
}; };
} }
@@ -273,15 +273,13 @@ fn render_execution(funcs: &CommonFunctions, field: &FullTypeFields) -> rust::To
return vec![$(output_type) { return vec![$(output_type) {
proc: self.proc.clone(), proc: self.proc.clone(),
selection: query, selection: query,
conn: self.conn.clone(), graphql_client: self.graphql_client.clone(),
}] }]
}; };
} }
let graphql_client = rust::import("crate::client", "graphql_client");
quote! { quote! {
query.execute(&$graphql_client(&self.conn)).await query.execute(self.graphql_client.clone()).await
} }
} }

View File

@@ -12,15 +12,15 @@ use crate::utility::OptionExt;
pub fn render_object(funcs: &CommonFunctions, t: &FullType) -> eyre::Result<rust::Tokens> { pub fn render_object(funcs: &CommonFunctions, t: &FullType) -> eyre::Result<rust::Tokens> {
let selection = rust::import("crate::querybuilder", "Selection"); let selection = rust::import("crate::querybuilder", "Selection");
let child = rust::import("tokio::process", "Child"); let child = rust::import("tokio::process", "Child");
let conn = rust::import("dagger_core::connect_params", "ConnectParams"); let graphql_client = rust::import("dagger_core::graphql_client", "DynGraphQLClient");
let arc = rust::import("std::sync", "Arc"); let arc = rust::import("std::sync", "Arc");
Ok(quote! { Ok(quote! {
#[derive(Debug, Clone)] #[derive(Clone)]
pub struct $(t.name.pipe(|s| format_name(s))) { pub struct $(t.name.pipe(|s| format_name(s))) {
pub proc: $arc<$child>, pub proc: $arc<$child>,
pub selection: $selection, pub selection: $selection,
pub conn: $conn, pub graphql_client: $graphql_client
} }
$(t.fields.pipe(|f| render_optional_args(funcs, f))) $(t.fields.pipe(|f| render_optional_args(funcs, f)))

View File

@@ -5,7 +5,7 @@ edition = "2021"
readme = "README.md" readme = "README.md"
license-file = "LICENSE.MIT" license-file = "LICENSE.MIT"
description = "dagger sdk core library" description = "dagger sdk core library"
repository = "https://github.com/kjuulh/dagger-rs" repository = "https://github.com/kjuulh/dagger-sdk"
publish = true publish = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -17,14 +17,22 @@ tokio = { workspace = true }
tracing = { workspace = true } tracing = { workspace = true }
tracing-subscriber = { workspace = true } tracing-subscriber = { workspace = true }
base64 = "0.21.0"
gql_client = "1.0.7"
dirs = "4.0.0" dirs = "4.0.0"
flate2 = { version = "1.0.25", features = ["zlib"] } flate2 = { version = "1.0.25", features = ["rust_backend"] }
graphql-introspection-query = "0.2.0" graphql_client = { version = "0.12.0", features = [
graphql_client = { version = "0.12.0", features = ["reqwest"] } "reqwest-rustls",
"graphql_query_derive",
], default-features = false }
hex = "0.4.3" hex = "0.4.3"
hex-literal = "0.3.4" hex-literal = "0.3.4"
platform-info = "1.0.2" platform-info = "1.0.2"
reqwest = { version = "0.11.14", features = ["stream", "deflate"] } reqwest = { version = "0.11.14", features = [
"stream",
"rustls-tls",
], default-features = false }
sha2 = "0.10.6" sha2 = "0.10.6"
tar = "0.4.38" tar = "0.4.38"
tempfile = "3.3.0" tempfile = "3.3.0"
async-trait = "0.1.67"

View File

@@ -0,0 +1,375 @@
use reqwest::Error;
use reqwest::{Client, Url};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt::{self, Formatter};
use std::str::FromStr;
#[derive(Clone)]
pub struct GraphQLError {
message: String,
json: Option<Vec<GraphQLErrorMessage>>,
}
// https://spec.graphql.org/June2018/#sec-Errors
#[derive(Deserialize, Debug, Clone)]
#[allow(dead_code)]
pub struct GraphQLErrorMessage {
message: String,
locations: Option<Vec<GraphQLErrorLocation>>,
extensions: Option<HashMap<String, String>>,
path: Option<Vec<GraphQLErrorPathParam>>,
}
#[derive(Deserialize, Debug, Clone)]
#[allow(dead_code)]
pub struct GraphQLErrorLocation {
line: u32,
column: u32,
}
#[derive(Deserialize, Debug, Clone)]
#[serde(untagged)]
pub enum GraphQLErrorPathParam {
String(String),
Number(u32),
}
impl GraphQLError {
pub fn with_text(message: impl AsRef<str>) -> Self {
Self {
message: message.as_ref().to_string(),
json: None,
}
}
pub fn with_message_and_json(message: impl AsRef<str>, json: Vec<GraphQLErrorMessage>) -> Self {
Self {
message: message.as_ref().to_string(),
json: Some(json),
}
}
pub fn with_json(json: Vec<GraphQLErrorMessage>) -> Self {
Self::with_message_and_json("Look at json field for more details", json)
}
pub fn message(&self) -> &str {
&self.message
}
pub fn json(&self) -> Option<Vec<GraphQLErrorMessage>> {
self.json.clone()
}
}
fn format(err: &GraphQLError, f: &mut Formatter<'_>) -> fmt::Result {
// Print the main error message
writeln!(f, "\nGQLClient Error: {}", err.message)?;
// Check if query errors have been received
if err.json.is_none() {
return Ok(());
}
let errors = err.json.as_ref();
for err in errors.unwrap() {
writeln!(f, "Message: {}", err.message)?;
}
Ok(())
}
impl fmt::Display for GraphQLError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
format(self, f)
}
}
impl fmt::Debug for GraphQLError {
#[allow(clippy::needless_borrow)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
format(&self, f)
}
}
impl From<Error> for GraphQLError {
fn from(error: Error) -> Self {
Self {
message: error.to_string(),
json: None,
}
}
}
/// GQL client config
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ClientConfig {
/// the endpoint about graphql server
pub endpoint: String,
/// gql query timeout, unit: seconds
pub timeout: Option<u64>,
/// additional request header
pub headers: Option<HashMap<String, String>>,
/// request proxy
pub proxy: Option<GQLProxy>,
}
/// proxy type
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum ProxyType {
Http,
Https,
All,
}
/// proxy auth, basic_auth
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ProxyAuth {
pub username: String,
pub password: String,
}
/// request proxy
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct GQLProxy {
/// schema, proxy url
pub schema: String,
/// proxy type
pub type_: ProxyType,
/// auth
pub auth: Option<ProxyAuth>,
}
#[cfg(not(target_arch = "wasm32"))]
impl TryFrom<GQLProxy> for reqwest::Proxy {
type Error = GraphQLError;
fn try_from(gql_proxy: GQLProxy) -> Result<Self, Self::Error> {
let proxy = match gql_proxy.type_ {
ProxyType::Http => reqwest::Proxy::http(gql_proxy.schema),
ProxyType::Https => reqwest::Proxy::https(gql_proxy.schema),
ProxyType::All => reqwest::Proxy::all(gql_proxy.schema),
}
.map_err(|e| Self::Error::with_text(format!("{:?}", e)))?;
Ok(proxy)
}
}
#[derive(Clone, Debug)]
pub struct GQLClient {
config: ClientConfig,
}
#[derive(Serialize)]
struct RequestBody<T: Serialize> {
query: String,
variables: T,
}
#[derive(Deserialize, Debug)]
struct GraphQLResponse<T> {
data: Option<T>,
errors: Option<Vec<GraphQLErrorMessage>>,
}
impl GQLClient {
fn client(&self) -> Result<Client, GraphQLError> {
let mut builder = Client::builder().timeout(std::time::Duration::from_secs(
self.config.timeout.unwrap_or(5),
));
if let Some(proxy) = &self.config.proxy {
builder = builder.proxy(proxy.clone().try_into()?);
}
builder
.build()
.map_err(|e| GraphQLError::with_text(format!("Can not create client: {:?}", e)))
}
}
impl GQLClient {
pub fn new(endpoint: impl AsRef<str>) -> Self {
Self {
config: ClientConfig {
endpoint: endpoint.as_ref().to_string(),
timeout: None,
headers: Default::default(),
proxy: None,
},
}
}
pub fn new_with_headers(
endpoint: impl AsRef<str>,
headers: HashMap<impl ToString, impl ToString>,
) -> Self {
let _headers: HashMap<String, String> = headers
.iter()
.map(|(name, value)| (name.to_string(), value.to_string()))
.into_iter()
.collect();
Self {
config: ClientConfig {
endpoint: endpoint.as_ref().to_string(),
timeout: None,
headers: Some(_headers),
proxy: None,
},
}
}
pub fn new_with_config(config: ClientConfig) -> Self {
Self { config }
}
}
impl GQLClient {
pub async fn query<K>(&self, query: &str) -> Result<Option<K>, GraphQLError>
where
K: for<'de> Deserialize<'de>,
{
self.query_with_vars::<K, ()>(query, ()).await
}
pub async fn query_unwrap<K>(&self, query: &str) -> Result<K, GraphQLError>
where
K: for<'de> Deserialize<'de>,
{
self.query_with_vars_unwrap::<K, ()>(query, ()).await
}
pub async fn query_with_vars_unwrap<K, T: Serialize>(
&self,
query: &str,
variables: T,
) -> Result<K, GraphQLError>
where
K: for<'de> Deserialize<'de>,
{
match self.query_with_vars(query, variables).await? {
Some(v) => Ok(v),
None => Err(GraphQLError::with_text(format!(
"No data from graphql server({}) for this query",
self.config.endpoint
))),
}
}
pub async fn query_with_vars<K, T: Serialize>(
&self,
query: &str,
variables: T,
) -> Result<Option<K>, GraphQLError>
where
K: for<'de> Deserialize<'de>,
{
self.query_with_vars_by_endpoint(&self.config.endpoint, query, variables)
.await
}
async fn query_with_vars_by_endpoint<K, T: Serialize>(
&self,
endpoint: impl AsRef<str>,
query: &str,
variables: T,
) -> Result<Option<K>, GraphQLError>
where
K: for<'de> Deserialize<'de>,
{
let mut times = 1;
let mut endpoint = endpoint.as_ref().to_string();
let endpoint_url = Url::from_str(&endpoint).map_err(|e| {
GraphQLError::with_text(format!("Wrong endpoint: {}. {:?}", endpoint, e))
})?;
let schema = endpoint_url.scheme();
let host = endpoint_url
.host()
.ok_or_else(|| GraphQLError::with_text(format!("Wrong endpoint: {}", endpoint)))?;
let client: Client = self.client()?;
let body = RequestBody {
query: query.to_string(),
variables,
};
loop {
if times > 10 {
return Err(GraphQLError::with_text(format!(
"Many redirect location: {}",
endpoint
)));
}
let mut request = client.post(&endpoint).json(&body);
if let Some(headers) = &self.config.headers {
if !headers.is_empty() {
for (name, value) in headers {
request = request.header(name, value);
}
}
}
let raw_response = request.send().await?;
if let Some(location) = raw_response.headers().get(reqwest::header::LOCATION) {
let redirect_url = location.to_str().map_err(|e| {
GraphQLError::with_text(format!(
"Failed to parse response header: Location. {:?}",
e
))
})?;
// if the response location start with http:// or https://
if redirect_url.starts_with("http://") || redirect_url.starts_with("https://") {
times += 1;
endpoint = redirect_url.to_string();
continue;
}
// without schema
endpoint = if redirect_url.starts_with('/') {
format!("{}://{}{}", schema, host, redirect_url)
} else {
format!("{}://{}/{}", schema, host, redirect_url)
};
times += 1;
continue;
}
let status = raw_response.status();
let response_body_text = raw_response
.text()
.await
.map_err(|e| GraphQLError::with_text(format!("Can not get response: {:?}", e)))?;
let json: GraphQLResponse<K> =
serde_json::from_str(&response_body_text).map_err(|e| {
GraphQLError::with_text(format!(
"Failed to parse response: {:?}. The response body is: {}",
e, response_body_text
))
})?;
if !status.is_success() {
return Err(GraphQLError::with_message_and_json(
format!("The response is [{}]", status.as_u16()),
json.errors.unwrap_or_default(),
));
}
// Check if error messages have been received
if json.errors.is_some() {
return Err(GraphQLError::with_json(json.errors.unwrap_or_default()));
}
if json.data.is_none() {
tracing::warn!(
target = "gql-client",
response_text = response_body_text,
"The deserialized data is none, the response",
);
}
return Ok(json.data);
}
}
}

View File

@@ -0,0 +1,52 @@
use std::collections::HashMap;
use std::sync::Arc;
use async_trait::async_trait;
use base64::engine::general_purpose;
use base64::Engine;
use gql_client::ClientConfig;
use crate::connect_params::ConnectParams;
#[async_trait]
pub trait GraphQLClient {
async fn query(&self, query: &str) -> eyre::Result<Option<serde_json::Value>>;
}
pub type DynGraphQLClient = Arc<dyn GraphQLClient + Send + Sync>;
#[derive(Debug)]
pub struct DefaultGraphQLClient {
client: gql_client::Client,
}
impl DefaultGraphQLClient {
pub fn new(conn: &ConnectParams) -> Self {
let token = general_purpose::URL_SAFE.encode(format!("{}:", conn.session_token));
let mut headers = HashMap::new();
headers.insert("Authorization".to_string(), format!("Basic {}", token));
Self {
client: gql_client::Client::new_with_config(ClientConfig {
endpoint: conn.url(),
timeout: Some(1000),
headers: Some(headers),
proxy: None,
}),
}
}
}
#[async_trait]
impl GraphQLClient for DefaultGraphQLClient {
async fn query(&self, query: &str) -> eyre::Result<Option<serde_json::Value>> {
let res: Option<serde_json::Value> = self
.client
.query(&query)
.await
.map_err(|r| eyre::anyhow!(r.to_string()))?;
return Ok(res);
}
}

View File

@@ -7,6 +7,7 @@ pub mod config;
pub mod connect_params; pub mod connect_params;
pub mod downloader; pub mod downloader;
pub mod engine; pub mod engine;
pub mod graphql_client;
pub mod introspection; pub mod introspection;
pub mod logger; pub mod logger;
pub mod schema; pub mod schema;

View File

@@ -5,7 +5,7 @@ edition = "2021"
readme = "README.md" readme = "README.md"
license-file = "LICENSE.MIT" license-file = "LICENSE.MIT"
description = "A dagger sdk for rust, written in rust" 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 publish = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -20,9 +20,7 @@ serde_json = { workspace = true }
tracing.workspace = true tracing.workspace = true
tracing-subscriber.workspace = true tracing-subscriber.workspace = true
base64 = "0.21.0"
futures = "0.3.27" futures = "0.3.27"
gql_client = "1.0.7"
derive_builder = "0.12.0" derive_builder = "0.12.0"
[dev-dependencies] [dev-dependencies]

View File

@@ -35,7 +35,7 @@ async fn main() -> eyre::Result<()> {
.container() .container()
.from("nginx") .from("nginx")
.with_directory("/usr/share/nginx/html", build_dir.id().await?) .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?; .await?;
println!("published image to: {}", ref_); println!("published image to: {}", ref_);

View File

@@ -13,7 +13,7 @@ async fn main() -> eyre::Result<()> {
let ref_ = client let ref_ = client
.container() .container()
.build(context_dir.id().await?) .build(context_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?; .await?;
println!("published image to: {}", ref_); println!("published image to: {}", ref_);

View File

@@ -34,7 +34,7 @@ async fn main() -> eyre::Result<()> {
.container() .container()
.from("nginx") .from("nginx")
.with_directory("/usr/share/nginx/html", build_dir.id().await?) .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?; .await?;
println!("published image to: {}", ref_); println!("published image to: {}", ref_);

View File

@@ -39,7 +39,7 @@ async fn main() -> eyre::Result<()> {
"/usr/share/nginx/html", "/usr/share/nginx/html",
client.host().directory(output).id().await?, client.host().directory(output).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?; .await?;
println!("published image to: {}", ref_); println!("published image to: {}", ref_);

View File

@@ -1,12 +1,8 @@
use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
use base64::engine::general_purpose; use dagger_core::graphql_client::DefaultGraphQLClient;
use base64::Engine;
use gql_client::ClientConfig;
use dagger_core::config::Config; use dagger_core::config::Config;
use dagger_core::connect_params::ConnectParams;
use dagger_core::engine::Engine as DaggerEngine; use dagger_core::engine::Engine as DaggerEngine;
use crate::gen::Query; use crate::gen::Query;
@@ -25,26 +21,12 @@ pub async fn connect_opts(cfg: Config) -> eyre::Result<DaggerConn> {
let (conn, proc) = DaggerEngine::new().start(&cfg).await?; let (conn, proc) = DaggerEngine::new().start(&cfg).await?;
Ok(Arc::new(Query { Ok(Arc::new(Query {
conn,
proc: Arc::new(proc), proc: Arc::new(proc),
selection: query(), selection: query(),
graphql_client: Arc::new(DefaultGraphQLClient::new(&conn)),
})) }))
} }
pub fn graphql_client(conn: &ConnectParams) -> gql_client::Client {
let token = general_purpose::URL_SAFE.encode(format!("{}:", conn.session_token));
let mut headers = HashMap::new();
headers.insert("Authorization".to_string(), format!("Basic {}", token));
gql_client::Client::new_with_config(ClientConfig {
endpoint: conn.url(),
timeout: Some(1000),
headers: Some(headers),
proxy: None,
})
}
// Conn will automatically close on drop of proc // Conn will automatically close on drop of proc
#[cfg(test)] #[cfg(test)]

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,6 @@
use std::{collections::HashMap, ops::Add, sync::Arc}; use std::{collections::HashMap, ops::Add, sync::Arc};
use dagger_core::graphql_client::DynGraphQLClient;
use eyre::Context; use eyre::Context;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -116,7 +117,7 @@ impl Selection {
Ok(fields.join("{") + &"}".repeat(fields.len() - 1)) Ok(fields.join("{") + &"}".repeat(fields.len() - 1))
} }
pub async fn execute<D>(&self, gql_client: &gql_client::Client) -> eyre::Result<D> pub async fn execute<D>(&self, gql_client: DynGraphQLClient) -> eyre::Result<D>
where where
D: for<'de> Deserialize<'de>, D: for<'de> Deserialize<'de>,
{ {