mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-08-17 20:53:29 +02:00
Compare commits
12 Commits
refactor/d
...
feat/musl-
Author | SHA1 | Date | |
---|---|---|---|
c861e5ebcf
|
|||
2214a89964
|
|||
05074d807e
|
|||
258d9c2c92
|
|||
07005ba232
|
|||
d78fdeea9c
|
|||
98f23fa2a2
|
|||
9d6c68be39
|
|||
b66d1bf3e4
|
|||
2faabb0e50 | |||
11d20935c6 | |||
384294b390 |
150
.github/workflows/ci-multiplatform.yml
vendored
Normal file
150
.github/workflows/ci-multiplatform.yml
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
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
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: ${{ matrix.rust }}
|
||||
- name: Use Cross
|
||||
if: matrix.target != ''
|
||||
run: |
|
||||
cargo install cross
|
||||
echo "CARGO=cross" >> $GITHUB_ENV
|
||||
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
|
||||
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
|
||||
- name: Show command used for Cargo
|
||||
run: |
|
||||
echo "cargo command is: ${{ env.CARGO }}"
|
||||
echo "target flag is: ${{ env.TARGET_FLAGS }}"
|
||||
- name: Build
|
||||
run: ${{ env.CARGO }} build --verbose --workspace ${{ env.TARGET_FLAGS }}
|
||||
- name: Run tests (without cross)
|
||||
if: matrix.target == ''
|
||||
run: ${{ env.CARGO }} test --verbose --workspace ${{ env.TARGET_FLAGS }}
|
||||
#- name: Run tests (with cross)
|
||||
# if: matrix.target != ''
|
||||
# run: ${{ env.CARGO }} test --verbose --workspace ${{ env.TARGET_FLAGS }}
|
||||
test_multi_platform:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- macos-latest
|
||||
- ubuntu-latest
|
||||
#- windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install packages (macOS)
|
||||
if: matrix.os == 'macos-latest'
|
||||
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
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: nightly
|
||||
- name: Run unit tests
|
||||
run: cargo test --locked --all-targets --workspace --all-features
|
||||
timeout-minutes: 10
|
||||
rustfmt:
|
||||
name: rustfmt
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Install Rust
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: stable
|
||||
components: rustfmt
|
||||
- name: Check formatting
|
||||
run: cargo fmt --all --check
|
@@ -1,7 +1,7 @@
|
||||
# Architecture
|
||||
|
||||
- `.` Root project mainly used for generating the CLI, which in turn is used to
|
||||
bootstrap the code generation from `dagger`
|
||||
- `crates/dagger-bootstrap` 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.)
|
||||
|
413
Cargo.lock
generated
413
Cargo.lock
generated
@@ -24,16 +24,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e"
|
||||
|
||||
[[package]]
|
||||
name = "async-compression"
|
||||
version = "0.3.15"
|
||||
name = "async-trait"
|
||||
version = "0.1.67"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "942c7cd7ae39e91bde4820d74132e9862e62c2f386c3aa90ccf55949f5bad63a"
|
||||
checksum = "86ea188f25f0255d8f92797797c97ebf5631fa88178beb1a46fdf5622c9a00e4"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"futures-core",
|
||||
"memchr",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -69,6 +67,12 @@ version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d5dd14596c0e5b954530d0e6f1fd99b89c03e313aa2086e8da4303701a09e1cf"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
@@ -121,11 +125,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.1.8"
|
||||
version = "4.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5"
|
||||
checksum = "42dfd32784433290c51d92c438bb72ea5063797fc3cc9a21a8c4346bebbb2098"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.0.1",
|
||||
"clap_lex",
|
||||
"is-terminal",
|
||||
"strsim",
|
||||
@@ -134,9 +138,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.3.2"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09"
|
||||
checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646"
|
||||
dependencies = [
|
||||
"os_str_bytes",
|
||||
]
|
||||
@@ -190,22 +194,6 @@ dependencies = [
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.5"
|
||||
@@ -241,7 +229,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dagger-bootstrap"
|
||||
version = "0.2.10"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"color-eyre",
|
||||
"dagger-codegen",
|
||||
"dagger-core",
|
||||
"eyre",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -262,10 +264,11 @@ dependencies = [
|
||||
name = "dagger-core"
|
||||
version = "0.2.8"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64",
|
||||
"dirs",
|
||||
"eyre",
|
||||
"flate2",
|
||||
"graphql-introspection-query",
|
||||
"graphql_client",
|
||||
"hex",
|
||||
"hex-literal",
|
||||
@@ -281,42 +284,15 @@ dependencies = [
|
||||
"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]]
|
||||
name = "dagger-sdk"
|
||||
version = "0.2.19"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"dagger-core",
|
||||
"derive_builder",
|
||||
"eyre",
|
||||
"futures",
|
||||
"genco",
|
||||
"gql_client",
|
||||
"pretty_assertions",
|
||||
"rand",
|
||||
"serde",
|
||||
@@ -348,7 +324,7 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -359,7 +335,7 @@ checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -380,7 +356,7 @@ dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -390,7 +366,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e"
|
||||
dependencies = [
|
||||
"derive_builder_core",
|
||||
"syn",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -503,7 +479,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"libz-sys",
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
@@ -513,21 +488,6 @@ version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
||||
dependencies = [
|
||||
"foreign-types-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types-shared"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.1.0"
|
||||
@@ -593,7 +553,7 @@ checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -645,7 +605,7 @@ checksum = "c85fd34848b1f708e6344a4af6f7bfc05172ae20ce4b35c8e417efffb4f306aa"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -675,18 +635,6 @@ version = "0.27.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4"
|
||||
|
||||
[[package]]
|
||||
name = "gql_client"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e57f4862d3e5cd4ffe8df03fa2137e620e33578bbc1895e6f8f569630e17b1db"
|
||||
dependencies = [
|
||||
"log",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "graphql-introspection-query"
|
||||
version = "0.2.0"
|
||||
@@ -732,7 +680,7 @@ dependencies = [
|
||||
"quote",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"syn",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -743,7 +691,7 @@ checksum = "d52fc9cde811f44b15ec0692b31e56a3067f6f431c5ace712f286e47c1dacc98"
|
||||
dependencies = [
|
||||
"graphql_client_codegen",
|
||||
"proc-macro2",
|
||||
"syn",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -863,16 +811,16 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-tls"
|
||||
version = "0.5.0"
|
||||
name = "hyper-rustls"
|
||||
version = "0.23.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
|
||||
checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"http",
|
||||
"hyper",
|
||||
"native-tls",
|
||||
"rustls",
|
||||
"tokio",
|
||||
"tokio-native-tls",
|
||||
"tokio-rustls",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -918,10 +866,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "io-lifetimes"
|
||||
version = "1.0.6"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3"
|
||||
checksum = "0dd6da19f25979c7270e70fa95ab371ec3b701cd0eefc47667a09785b3c59155"
|
||||
dependencies = [
|
||||
"hermit-abi 0.3.1",
|
||||
"libc",
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
@@ -934,9 +883,9 @@ checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146"
|
||||
|
||||
[[package]]
|
||||
name = "is-terminal"
|
||||
version = "0.4.4"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857"
|
||||
checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e"
|
||||
dependencies = [
|
||||
"hermit-abi 0.3.1",
|
||||
"io-lifetimes",
|
||||
@@ -980,17 +929,6 @@ version = "0.2.140"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.1.4"
|
||||
@@ -1058,24 +996,6 @@ dependencies = [
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "native-tls"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"log",
|
||||
"openssl",
|
||||
"openssl-probe",
|
||||
"openssl-sys",
|
||||
"schannel",
|
||||
"security-framework",
|
||||
"security-framework-sys",
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.46.0"
|
||||
@@ -1111,51 +1031,6 @@ version = "1.17.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.10.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"openssl-macros",
|
||||
"openssl-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-macros"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-probe"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "6.4.1"
|
||||
@@ -1224,12 +1099,6 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
|
||||
|
||||
[[package]]
|
||||
name = "platform-info"
|
||||
version = "1.0.2"
|
||||
@@ -1312,7 +1181,7 @@ version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 1.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1362,7 +1231,6 @@ version = "0.11.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9"
|
||||
dependencies = [
|
||||
"async-compression",
|
||||
"base64",
|
||||
"bytes",
|
||||
"encoding_rs",
|
||||
@@ -1372,20 +1240,21 @@ dependencies = [
|
||||
"http",
|
||||
"http-body",
|
||||
"hyper",
|
||||
"hyper-tls",
|
||||
"hyper-rustls",
|
||||
"ipnet",
|
||||
"js-sys",
|
||||
"log",
|
||||
"mime",
|
||||
"native-tls",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"rustls",
|
||||
"rustls-pemfile",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"tokio",
|
||||
"tokio-native-tls",
|
||||
"tokio-rustls",
|
||||
"tokio-util",
|
||||
"tower-service",
|
||||
"url",
|
||||
@@ -1393,9 +1262,25 @@ dependencies = [
|
||||
"wasm-bindgen-futures",
|
||||
"wasm-streams",
|
||||
"web-sys",
|
||||
"webpki-roots",
|
||||
"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]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.21"
|
||||
@@ -1404,11 +1289,11 @@ checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.36.9"
|
||||
version = "0.36.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc"
|
||||
checksum = "2fe885c3a125aa45213b68cc1472a49880cb5923dc23f522ad2791b882228778"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 1.3.2",
|
||||
"errno",
|
||||
"io-lifetimes",
|
||||
"libc",
|
||||
@@ -1416,21 +1301,33 @@ dependencies = [
|
||||
"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]]
|
||||
name = "ryu"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041"
|
||||
|
||||
[[package]]
|
||||
name = "schannel"
|
||||
version = "0.1.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3"
|
||||
dependencies = [
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.1.0"
|
||||
@@ -1438,46 +1335,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
name = "security-framework"
|
||||
version = "2.8.2"
|
||||
name = "sct"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254"
|
||||
checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"core-foundation",
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
"security-framework-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "security-framework-sys"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
"ring",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.156"
|
||||
version = "1.0.157"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "314b5b092c0ade17c00142951e50ced110ec27cea304b1037c6969246c2469a4"
|
||||
checksum = "707de5fcf5df2b5788fca98dd7eab490bc2fd9b7ef1404defc462833b83f25ca"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.156"
|
||||
version = "1.0.157"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d"
|
||||
checksum = "78997f4555c22a7971214540c4a661291970619afd56de19f77e0de86296e1e5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1557,6 +1441,12 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
@@ -1574,6 +1464,17 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59d3276aee1fa0c33612917969b5172b5be2db051232a6e4826f1a1a9191b045"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tar"
|
||||
version = "0.4.38"
|
||||
@@ -1609,22 +1510,22 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.39"
|
||||
version = "1.0.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c"
|
||||
checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.39"
|
||||
version = "1.0.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e"
|
||||
checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 2.0.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1680,17 +1581,18 @@ checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-native-tls"
|
||||
version = "0.3.1"
|
||||
name = "tokio-rustls"
|
||||
version = "0.23.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
|
||||
checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59"
|
||||
dependencies = [
|
||||
"native-tls",
|
||||
"rustls",
|
||||
"tokio",
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1734,7 +1636,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1806,7 +1708,7 @@ checksum = "258bc1c4f8e2e73a977812ab339d503e6feeb92700f6d07a6de4d321522d5c08"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1823,9 +1725,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.11"
|
||||
version = "0.3.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c"
|
||||
checksum = "7d502c968c6a838ead8e69b2ee18ec708802f99db92a0d156705ec9ef801993b"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
@@ -1857,6 +1759,12 @@ dependencies = [
|
||||
"void",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "untrusted"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.3.1"
|
||||
@@ -1874,12 +1782,6 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
@@ -1929,7 +1831,7 @@ dependencies = [
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.109",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
@@ -1963,7 +1865,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"syn 1.0.109",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
@@ -1997,6 +1899,25 @@ dependencies = [
|
||||
"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]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
|
@@ -3,14 +3,14 @@ members = [
|
||||
"crates/dagger-codegen",
|
||||
"crates/dagger-sdk",
|
||||
"crates/dagger-core",
|
||||
"crates/dagger-rs",
|
||||
"crates/dagger-bootstrap",
|
||||
"ci",
|
||||
]
|
||||
|
||||
[workspace.dependencies]
|
||||
dagger-codegen = { path = "crates/dagger-codegen", version = "^0.2.5" }
|
||||
dagger-core = { path = "crates/dagger-core", version = "^0.2.8" }
|
||||
dagger-rs = { path = "crates/dagger-rs", version = "^0.2.10" }
|
||||
dagger-bootstrap = { path = "crates/dagger-bootstrap", version = "^0.2.10" }
|
||||
dagger-sdk = { path = "crates/dagger-sdk", version = "^0.2.19" }
|
||||
|
||||
eyre = "0.6.8"
|
||||
|
2
Cross.toml
Normal file
2
Cross.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[target.x86_64-unknown-linux-musl]
|
||||
image = "messense/rust-musl-cross:x86_64-musl"
|
@@ -8,7 +8,7 @@ command = "cargo"
|
||||
args = [
|
||||
"run",
|
||||
"-p",
|
||||
"dagger-rs",
|
||||
"dagger-bootstrap",
|
||||
"--",
|
||||
"generate",
|
||||
"--output",
|
||||
|
4
ci/scripts/macos-install-packages
Executable file
4
ci/scripts/macos-install-packages
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
brew install docker
|
||||
colima start
|
@@ -90,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?;
|
||||
|
@@ -1,11 +1,11 @@
|
||||
[package]
|
||||
name = "dagger-rs"
|
||||
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-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
|
||||
@@ -21,14 +21,3 @@ 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"
|
@@ -5,7 +5,7 @@ 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
|
||||
|
||||
|
@@ -247,7 +247,7 @@ fn render_execution(funcs: &CommonFunctions, field: &FullTypeFields) -> rust::To
|
||||
return $(output_type) {
|
||||
proc: self.proc.clone(),
|
||||
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) {
|
||||
proc: self.proc.clone(),
|
||||
selection: query,
|
||||
conn: self.conn.clone(),
|
||||
graphql_client: self.graphql_client.clone(),
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
let graphql_client = rust::import("crate::client", "graphql_client");
|
||||
|
||||
quote! {
|
||||
query.execute(&$graphql_client(&self.conn)).await
|
||||
query.execute(self.graphql_client.clone()).await
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,15 +12,15 @@ 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("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");
|
||||
|
||||
Ok(quote! {
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Clone)]
|
||||
pub struct $(t.name.pipe(|s| format_name(s))) {
|
||||
pub proc: $arc<$child>,
|
||||
pub selection: $selection,
|
||||
pub conn: $conn,
|
||||
pub graphql_client: $graphql_client
|
||||
}
|
||||
|
||||
$(t.fields.pipe(|f| render_optional_args(funcs, f)))
|
||||
|
@@ -5,7 +5,7 @@ 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
|
||||
|
||||
@@ -17,14 +17,22 @@ tokio = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
tracing-subscriber = { workspace = true }
|
||||
|
||||
base64 = "0.21.0"
|
||||
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"] }
|
||||
flate2 = { version = "1.0.25", features = ["rust_backend"] }
|
||||
graphql_client = { version = "0.12.0", features = [
|
||||
"reqwest-rustls",
|
||||
"graphql_query_derive",
|
||||
], default-features = false }
|
||||
hex = "0.4.3"
|
||||
hex-literal = "0.3.4"
|
||||
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"
|
||||
tar = "0.4.38"
|
||||
tempfile = "3.3.0"
|
||||
async-trait = "0.1.67"
|
||||
|
375
crates/dagger-core/src/gql_client.rs
Normal file
375
crates/dagger-core/src/gql_client.rs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
52
crates/dagger-core/src/graphql_client.rs
Normal file
52
crates/dagger-core/src/graphql_client.rs
Normal 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 crate::connect_params::ConnectParams;
|
||||
use crate::gql_client::{ClientConfig, GQLClient};
|
||||
|
||||
#[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: GQLClient,
|
||||
}
|
||||
|
||||
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: GQLClient::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);
|
||||
}
|
||||
}
|
@@ -7,6 +7,8 @@ pub mod config;
|
||||
pub mod connect_params;
|
||||
pub mod downloader;
|
||||
pub mod engine;
|
||||
pub mod gql_client;
|
||||
pub mod graphql_client;
|
||||
pub mod introspection;
|
||||
pub mod logger;
|
||||
pub mod schema;
|
||||
|
@@ -5,7 +5,7 @@ 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
|
||||
@@ -20,9 +20,7 @@ serde_json = { workspace = true }
|
||||
tracing.workspace = true
|
||||
tracing-subscriber.workspace = true
|
||||
|
||||
base64 = "0.21.0"
|
||||
futures = "0.3.27"
|
||||
gql_client = "1.0.7"
|
||||
derive_builder = "0.12.0"
|
||||
|
||||
[dev-dependencies]
|
||||
|
@@ -35,7 +35,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_);
|
||||
|
@@ -13,7 +13,7 @@ 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>()))
|
||||
.publish(format!("ttl.sh/hello-dagger-sdk-{}:1h", rng.gen::<u64>()))
|
||||
.await?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
@@ -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_);
|
||||
|
@@ -39,7 +39,7 @@ 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>()))
|
||||
.publish(format!("ttl.sh/hello-dagger-sdk-{}:1h", rng.gen::<u64>()))
|
||||
.await?;
|
||||
|
||||
println!("published image to: {}", ref_);
|
||||
|
@@ -1,12 +1,8 @@
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use base64::engine::general_purpose;
|
||||
use base64::Engine;
|
||||
use gql_client::ClientConfig;
|
||||
use dagger_core::graphql_client::DefaultGraphQLClient;
|
||||
|
||||
use dagger_core::config::Config;
|
||||
use dagger_core::connect_params::ConnectParams;
|
||||
use dagger_core::engine::Engine as DaggerEngine;
|
||||
|
||||
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?;
|
||||
|
||||
Ok(Arc::new(Query {
|
||||
conn,
|
||||
proc: Arc::new(proc),
|
||||
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
|
||||
|
||||
#[cfg(test)]
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
use std::{collections::HashMap, ops::Add, sync::Arc};
|
||||
|
||||
use dagger_core::graphql_client::DynGraphQLClient;
|
||||
use eyre::Context;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -116,7 +117,7 @@ impl Selection {
|
||||
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
|
||||
D: for<'de> Deserialize<'de>,
|
||||
{
|
||||
|
Reference in New Issue
Block a user