Compare commits

...

89 Commits

Author SHA1 Message Date
1725c5188e Release dagger-core v0.2.5, dagger-sdk v0.2.12, dagger-codegen v0.2.7 2023-02-20 11:42:14 +01:00
a13a2a9ecb fix(all): race condition in process 2023-02-20 11:42:03 +01:00
b86710d71e revert disable caching 2023-02-20 11:28:24 +01:00
08a2e30967 disable cache 2023-02-20 10:56:56 +01:00
b552dc5d75 chore(ci): with dagger v0.2.11 2023-02-20 10:50:48 +01:00
f869e574dd Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 2023-02-20 10:48:05 +01:00
921e61b5e2 fix(core): remove blocking 2023-02-20 10:47:58 +01:00
17ec62a5d5 Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 2023-02-20 10:42:12 +01:00
803cfc4f8c chore(sdk): ran clippy 2023-02-20 10:42:00 +01:00
8385aa8a15 fix(all): remove blocking 2023-02-20 10:40:53 +01:00
60f2cb2f2e Release ci v0.1.0 2023-02-20 10:39:10 +01:00
30b7511e45 docs(ci): add changelog 2023-02-20 10:39:06 +01:00
06e2638e1f chore(ci): with actual await on connect 2023-02-20 10:33:14 +01:00
48433cf368 chore(ci): with dagger v0.2.10 2023-02-20 10:30:33 +01:00
fc01755b99 Release dagger-rs v0.2.10 2023-02-20 10:29:00 +01:00
5cb97296b6 Release dagger-sdk v0.2.10 2023-02-20 10:28:24 +01:00
b100285312 fix(docs): changelog 2023-02-20 10:28:13 +01:00
8ed06476e5 Adjusting changelogs prior to release of dagger-sdk v0.2.10 2023-02-20 10:27:15 +01:00
09aa658b6f update changelog 2023-02-20 10:27:09 +01:00
b436f27a53 Adjusting changelogs prior to release of dagger-sdk v0.2.10 2023-02-20 10:26:31 +01:00
577a293c67 Adjusting changelogs prior to release of dagger-sdk v0.2.10, dagger-rs v0.2.10 2023-02-20 10:26:05 +01:00
76bb1fcedd Adjusting changelogs prior to release of dagger-sdk v0.2.10, dagger-rs v0.2.10 2023-02-20 10:25:45 +01:00
dc3487b840 Release dagger-rs v0.2.10 2023-02-20 10:25:15 +01:00
0c21d58c71 Release dagger-rs v0.2.10 2023-02-20 10:24:29 +01:00
e3fd23c64e Release dagger-rs v0.2.10 2023-02-20 10:23:07 +01:00
82de43aa91 Release dagger-core v0.2.3, dagger-sdk v0.2.9, dagger-rs v0.2.10 2023-02-20 10:21:34 +01:00
f40ba9b403 fix(ci): with older version of dagger-sdk 2023-02-20 10:19:43 +01:00
75bc17e57d fix(core): Fix async panic on blocking #19
Replaced internal threads with tokio spawn functions
2023-02-20 10:19:43 +01:00
45d6462037 chore(ci): with async/await 2023-02-19 22:51:34 +01:00
04990247ba Release dagger-sdk v0.2.8, dagger-codegen v0.2.5 2023-02-19 22:43:48 +01:00
978ede68ae feat(sdk): add documentation strings 2023-02-19 22:43:12 +01:00
a1887afc8b Release dagger-sdk v0.2.7 2023-02-19 21:48:55 +01:00
d3faa996e6 docs: check async variant 2023-02-19 21:48:30 +01:00
93f40b356c docs(sdk): change to await syntax 2023-02-19 21:47:40 +01:00
9be6f435d9 feat(sdk,core): Use async runtime instead of blocking.
Default to using async runtime instead of blocking. I.e.

```rust
fn main() -> eyre::Result<()> {
  // ...

  client.container().from("rust").publish("somewhere")?;

  // ...
}

// to

async fn main() -> eyre::Result<()> {
  // ...

  client.container().from("rust").publish("somewhere").await?;

  // ...
}
```
2023-02-19 21:47:40 +01:00
c35c104b49 chore(ci): update ci to use dagger-sdk v0.2.6 2023-02-19 18:28:47 +01:00
c312bc57ad Release dagger-sdk v0.2.6 2023-02-19 18:04:24 +01:00
04e70ce964 docs: fix readme 2023-02-19 18:04:10 +01:00
f72731807d Release dagger-sdk v0.2.5, dagger-codegen v0.2.4 2023-02-19 18:00:27 +01:00
c627595fd2 fix: cargo clippy 2023-02-19 18:00:04 +01:00
3f13c40ab8 fix: roadmap item api stabilization 2023-02-19 18:00:04 +01:00
f29ff836cf feat(sdk): without Some in _opts functions
Option has been removed as a wrapper around opts. This makes it much
more convenient to use

```rust
client.container_opts(Some(ContainerOpts{}))
// ->
client.container_opts(ContainerOpts{})
```

The same options are still available, either an empty object can be
passed, or a non _opts function can be used
2023-02-19 18:00:04 +01:00
9762da895a feat(sdk): with _opts methods
Now all opt values enter into a _opts function instead of the original.
This avoids a lot of verbosity for both None in the case opts are
unwanted, and Some() if they actually are.

They are used like so:

```rust
client.container().from("...");
client.container_opts(Some(ContainerOpts{ ... }))
```

Some from opts will be removed in a future commit/pr
2023-02-19 18:00:04 +01:00
02006d40fc fix(sdk): without phantom data 2023-02-19 18:00:04 +01:00
94336d0637 feat(sdk): move to &str instead of String and introduce builder.
This will make the api much easier to use, as we can now rely on ""
instead of "".into() for normal string values.

Introduced builder as well, which makes it much easier to use *Opts, as
it can handle the building of that, and get the benefits from String ->
&str, as that is currently not allowed for optional values
2023-02-19 18:00:04 +01:00
6e2292cf11 fix(sdk): dependencies 2023-02-19 15:39:10 +01:00
cc81124f89 Release dagger-sdk v0.2.4 2023-02-19 15:34:07 +01:00
7d04ab1240 fix(sdk): readme dagger-rs -> dagger-sdk 2023-02-19 15:33:48 +01:00
92350306b3 Release dagger-sdk v0.2.3, dagger-codegen v0.2.3, dagger-rs v0.2.9 2023-02-19 15:30:08 +01:00
19ed6c267f feat(sdk): re-export through lib.rs
this means that you can now use dagger_sdk::connect() instead of
dagger_sdk::client::connect();
2023-02-19 15:29:03 +01:00
de063eae85 feat(sdk): with return result instead of unwrap 2023-02-19 15:29:03 +01:00
5d66736990 feat(core,sdk): remove unnecessary option returns 2023-02-19 15:29:03 +01:00
9ada74960a feat(ci): add gha caching 2023-02-19 14:41:23 +01:00
90ab2e2b7d feat: clear release-cycle roadmap item 2023-02-19 14:37:23 +01:00
818ef6f74d feat(ci): lint pr 2023-02-19 12:57:32 +01:00
691ecfbf52 feat(ci): ci with dagger v0.2.2 2023-02-19 12:44:03 +01:00
e921ba1363 Release dagger-sdk v0.2.2 2023-02-19 12:30:59 +01:00
1638f15fba Release dagger-core v0.2.2, dagger-codegen v0.2.2, dagger-rs v0.2.8 2023-02-19 12:27:28 +01:00
10bc6f3846 fix(sdk): fixed fmt errors 2023-02-19 12:23:20 +01:00
6e5f407432 feat(sdk): update to dagger v0.3.12 2023-02-19 12:23:20 +01:00
3cb83bb79c with bin cache 2023-02-19 11:47:55 +01:00
Renovate Bot
199fe16dbf fix(deps): update rust crate dagger-sdk to 0.2.1 2023-02-18 17:34:50 +01:00
3cfd032a85 add cache 2023-02-18 17:13:41 +01:00
83ae5b476a fix(ci): fix github secret naming 2023-02-18 17:05:40 +01:00
60dfad0aaa run everywhere 2023-02-18 17:04:40 +01:00
25fb9d4f24 fix(ci): with secret 2023-02-18 17:03:37 +01:00
f42da8416a feat(ci): with sccache 2023-02-18 16:57:35 +01:00
98781f2496 test change 2023-02-18 16:06:34 +01:00
aa0c397b15 Release dagger-sdk v0.2.1 2023-02-18 16:05:10 +01:00
11a5247933 add dagger-sdk changelog 2023-02-18 16:04:39 +01:00
20c71189f6 Release dagger-rs v0.2.7, dagger-sdk v0.2.1 2023-02-18 16:03:59 +01:00
d72313051b fix: with test changes 2023-02-18 15:57:16 +01:00
a2036838de Release dagger-rs v0.2.6 2023-02-18 15:19:42 +01:00
4ebe0d12b5 fix: cleanup 2023-02-18 15:19:38 +01:00
084ffafa3e Release dagger-rs v0.2.5 2023-02-18 15:18:47 +01:00
5c9ab3756b Release dagger-rs v0.2.4 2023-02-18 15:16:56 +01:00
4ac89b6457 fix: trying agian 2023-02-18 15:16:51 +01:00
4b9f1e4320 Release dagger-rs v0.2.3 2023-02-18 15:11:38 +01:00
3a45202a21 feat: some test 2023-02-18 15:11:29 +01:00
7c8d8a3e9c Release dagger-rs v0.2.2 2023-02-18 15:09:24 +01:00
0470093912 with test commit 2023-02-18 15:09:08 +01:00
4d60d25a1f feature: trying smart-release 2023-02-18 15:08:28 +01:00
1332bc842c Release dagger-core v0.2.1, dagger-codegen v0.2.1, dagger-rs v0.2.1 2023-02-18 15:05:46 +01:00
a064684fcf add changelogs 2023-02-18 15:05:42 +01:00
922ad3a794 Release dagger-core v0.2.1, dagger-codegen v0.2.1, dagger-rs v0.2.1 2023-02-18 15:05:24 +01:00
a7d97c2342 update changelog 2023-02-18 15:05:18 +01:00
f4a20fda79 Adjusting changelogs prior to release of dagger-core v0.2.1, dagger-codegen v0.2.1, dagger-rs v0.2.1 2023-02-18 15:04:11 +01:00
32665d8fa0 add color eyre 2023-02-18 15:03:57 +01:00
03e022fcac feature with workspace (#8)
* add ci

* with description

* fix warnings

* with actual test

* leave out tests for now as they rely on dind

* with workspace
2023-02-18 00:48:59 +00:00
44 changed files with 3872 additions and 1151 deletions

View File

@@ -1,8 +1,14 @@
name: ci
on:
pull_request:
push:
branches:
- "main"
env:
CARGO_TERM_COLOR: always
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
_EXPERIMENTAL_DAGGER_CACHE_CONFIG: type=gha;mode=max
jobs:
deploy:
runs-on: ubuntu-latest
@@ -11,5 +17,16 @@ jobs:
uses: actions/checkout@v3
- name: Update rust toolchain
run: rustup update stable && rustup default stable
- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: "~/.cargo/bin/\n~/.cargo/registry/index/\n~/.cargo/registry/cache/\n~/.cargo/git/db/\ntarget/"
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.0.0
- name: Run dagger [CI]
run: cargo run -p ci -- pr

View File

@@ -1,21 +0,0 @@
name: Release
permissions:
contents: write
on:
push:
tags:
- v[0-9]+.*
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: taiki-e/create-gh-release-action@v1
with:
# (Optional) Path to changelog.
changelog: CHANGELOG.md
# (Optional) Create a draft release.
# [default value: false]
draft: true
# (Required) GitHub token for creating GitHub Releases.
token: ${{ secrets.GITHUB_TOKEN }}

15
.github/workflows/lint-pr.yml vendored Normal file
View File

@@ -0,0 +1,15 @@
name: "Lint PR"
on:
pull_request_target:
types:
- opened
- edited
- synchronize
jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,8 +1,266 @@
## 0.2.0 - 2023-02-17
# Changelog
First actual useful version of dagger-sdk. contains code for codegen, cli, and
core.
All notable changes to this project will be documented in this file.
## 0.2.6 - 2023-02-17
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v0.2.10 (2023-02-20)
### Bug Fixes
- <csr-id-75bc17e57db222492c6ffd2dfe80208d2bda75c9/> Fix async panic on blocking #19
Replaced internal threads with tokio spawn functions
### Commit Statistics
<csr-read-only-do-not-edit/>
- 1 commit contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Fix async panic on blocking #19 ([`75bc17e`](https://github.com/kjuulh/dagger-rs/commit/75bc17e57db222492c6ffd2dfe80208d2bda75c9))
</details>
## v0.2.9 (2023-02-19)
### New Features
- <csr-id-19ed6c267f779b72430422c463ceed553f6fc618/> re-export through lib.rs
this means that you can now use dagger_sdk::connect() instead of
dagger_sdk::client::connect();
### Commit Statistics
<csr-read-only-do-not-edit/>
- 1 commit contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- re-export through lib.rs ([`19ed6c2`](https://github.com/kjuulh/dagger-rs/commit/19ed6c267f779b72430422c463ceed553f6fc618))
</details>
## v0.2.8 (2023-02-19)
### New Features
- <csr-id-f42da8416a5450c7c3c924353c3cc9112afd18f0/> with sccache
### Commit Statistics
<csr-read-only-do-not-edit/>
- 2 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- with sccache ([`f42da84`](https://github.com/kjuulh/dagger-rs/commit/f42da8416a5450c7c3c924353c3cc9112afd18f0))
- test change ([`98781f2`](https://github.com/kjuulh/dagger-rs/commit/98781f2496deaea4bc13c9e90e60543b7daac9d7))
</details>
## v0.2.7 (2023-02-18)
### Bug Fixes
- <csr-id-d72313051b9b46a6eeaa909a11850b3d8fc75e81/> with test changes
### Commit Statistics
<csr-read-only-do-not-edit/>
- 1 commit contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- with test changes ([`d723130`](https://github.com/kjuulh/dagger-rs/commit/d72313051b9b46a6eeaa909a11850b3d8fc75e81))
</details>
## v0.2.6 (2023-02-18)
With smart releaser
### Bug Fixes
- <csr-id-4ebe0d12b50028a8b79d8c76a2257c9c2b7b3429/> cleanup
### Commit Statistics
<csr-read-only-do-not-edit/>
- 1 commit contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- cleanup ([`4ebe0d1`](https://github.com/kjuulh/dagger-rs/commit/4ebe0d12b50028a8b79d8c76a2257c9c2b7b3429))
</details>
## v0.2.5 (2023-02-18)
### Bug Fixes
- <csr-id-4ac89b645712dd8c357832a817af131c2d2e0686/> trying agian
### Commit Statistics
<csr-read-only-do-not-edit/>
- 1 commit contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- trying agian ([`4ac89b6`](https://github.com/kjuulh/dagger-rs/commit/4ac89b645712dd8c357832a817af131c2d2e0686))
</details>
## v0.2.4 (2023-02-18)
### Bug Fixes
- <csr-id-4ac89b645712dd8c357832a817af131c2d2e0686/> trying agian
## v0.2.3 (2023-02-18)
### New Features
- <csr-id-3a45202a21b24d8331a2ead72944df9ac7c70839/> some test
### Commit Statistics
<csr-read-only-do-not-edit/>
- 1 commit contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- some test ([`3a45202`](https://github.com/kjuulh/dagger-rs/commit/3a45202a21b24d8331a2ead72944df9ac7c70839))
</details>
## v0.2.2 (2023-02-18)
### Commit Statistics
<csr-read-only-do-not-edit/>
- 1 commit contributed to the release.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- with test commit ([`0470093`](https://github.com/kjuulh/dagger-rs/commit/0470093912622640913ac34661be72a546dd1ba5))
</details>
## v0.2.1 (2023-02-18)
### Commit Statistics
<csr-read-only-do-not-edit/>
- 1 commit contributed to the release.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- add color eyre ([`32665d8`](https://github.com/kjuulh/dagger-rs/commit/32665d8fa0c97d39a1b43c5e8343f23e87497c16))
</details>
## v0.2.0 (2023-02-17)
### Commit Statistics
<csr-read-only-do-not-edit/>
- 19 commits contributed to the release over the course of 21 calendar days.
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
- 1 unique issue was worked on: [#6](https://github.com/kjuulh/dagger-rs/issues/6)
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **[#6](https://github.com/kjuulh/dagger-rs/issues/6)**
- feature/add impl ([`4a4c03f`](https://github.com/kjuulh/dagger-rs/commit/4a4c03f3c2ee7f6268c65976715e70767b4ea78d))
* **Uncategorized**
- move code to dagger-core ([`ec0d0b2`](https://github.com/kjuulh/dagger-rs/commit/ec0d0b22e646c97acb3ce93f3afb3ddb8590e68f))
- add fields ([`496a687`](https://github.com/kjuulh/dagger-rs/commit/496a687bc34f7c58cc86df60c183be741b0b8a9c))
- with codegen output ([`0bf6b0e`](https://github.com/kjuulh/dagger-rs/commit/0bf6b0e91ecc31c1f6b51338234137eb185810a0))
- added scalars ([`e587414`](https://github.com/kjuulh/dagger-rs/commit/e5874141b3b6256b7ac2a0bf653089fa7bcc5d14))
- split out codegen parts ([`3263f1d`](https://github.com/kjuulh/dagger-rs/commit/3263f1d589aee78065401c666533cb0cbadd06ce))
- add collection of types ([`7433453`](https://github.com/kjuulh/dagger-rs/commit/7433453c6dd1447f8ad09c06c13a02cfac5ace05))
- with type filtering ([`2eb5d98`](https://github.com/kjuulh/dagger-rs/commit/2eb5d98c8a28ab8dfdc4eb959809191bc483bd08))
- with fixes ([`3eb8914`](https://github.com/kjuulh/dagger-rs/commit/3eb891422fa1404f88cfe259bddbb67e2843f1d3))
- add todo for not dropping proc ([`b63c44a`](https://github.com/kjuulh/dagger-rs/commit/b63c44adedfa0c8ef4899198bea75a5744570a87))
- can get schema ([`06fd730`](https://github.com/kjuulh/dagger-rs/commit/06fd730a1c23af88eaffa1dde8acdea202247f91))
- with session ([`83ecbd2`](https://github.com/kjuulh/dagger-rs/commit/83ecbd238ab87396c9645cb93741e89a34c92766))
- with engine ([`ee655d0`](https://github.com/kjuulh/dagger-rs/commit/ee655d02ef9670b2c0cbaa600c3e2af9f54dbf65))
- Can download dagger ([`1e88bb3`](https://github.com/kjuulh/dagger-rs/commit/1e88bb327035bd156588716202b8d982a50c114c))
- with out keeper ([`59e59fd`](https://github.com/kjuulh/dagger-rs/commit/59e59fd55d17f7e24ccb3c64471bf82332af5a21))
- more allow dead_code ([`a804dd9`](https://github.com/kjuulh/dagger-rs/commit/a804dd97a6ed08ad51c8552bc5d4c845491dca1c))
- allow dead_code ([`e2d32ed`](https://github.com/kjuulh/dagger-rs/commit/e2d32ede7621123a3db9d5e2cd3e7d276d0b5e2f))
- without integration ([`b6186aa`](https://github.com/kjuulh/dagger-rs/commit/b6186aa9015f8ddb5d59d1346a2cdc935a26d061))
- Add base sdk ([`078e2d9`](https://github.com/kjuulh/dagger-rs/commit/078e2d9c2c43fc2b4752ab1dcf4627c840009992))
</details>
With releaser

261
Cargo.lock generated
View File

@@ -92,15 +92,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "bytes"
version = "1.3.0"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c"
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
[[package]]
name = "cc"
version = "1.0.78"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d"
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
[[package]]
name = "cfg-if"
@@ -114,8 +114,9 @@ version = "0.1.0"
dependencies = [
"clap",
"color-eyre",
"dagger-sdk 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dagger-sdk 0.2.11",
"eyre",
"tokio",
]
[[package]]
@@ -245,10 +246,10 @@ dependencies = [
[[package]]
name = "dagger-codegen"
version = "0.2.0"
version = "0.2.7"
dependencies = [
"convert_case",
"dagger-core 0.2.0",
"dagger-core 0.2.5",
"eyre",
"genco",
"itertools",
@@ -259,7 +260,9 @@ dependencies = [
[[package]]
name = "dagger-core"
version = "0.2.0"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71f74120a67a030e76c6039457909ba31e53fb022b0b633f5836f008eb4e1766"
dependencies = [
"clap",
"dirs",
@@ -277,13 +280,12 @@ dependencies = [
"sha2",
"tar",
"tempfile",
"tokio",
]
[[package]]
name = "dagger-core"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02a16b0e83ae5b88a3d4e2f3cf5149932cfcb3113e67f5579372e25d5dab5b53"
version = "0.2.5"
dependencies = [
"clap",
"dirs",
@@ -301,15 +303,17 @@ dependencies = [
"sha2",
"tar",
"tempfile",
"tokio",
]
[[package]]
name = "dagger-rs"
version = "0.2.0"
version = "0.2.10"
dependencies = [
"clap",
"color-eyre",
"dagger-codegen",
"dagger-core 0.2.0",
"dagger-core 0.2.5",
"dirs",
"eyre",
"flate2",
@@ -325,14 +329,33 @@ dependencies = [
"sha2",
"tar",
"tempfile",
"tokio",
]
[[package]]
name = "dagger-sdk"
version = "0.2.0"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d86c5bf1ad09a730d6fc5c73c39664eb38b9843fc21dedfee4629976ae04cba4"
dependencies = [
"base64",
"dagger-core 0.2.0",
"dagger-core 0.2.4",
"derive_builder",
"eyre",
"futures",
"gql_client",
"serde",
"serde_json",
"tokio",
]
[[package]]
name = "dagger-sdk"
version = "0.2.12"
dependencies = [
"base64",
"dagger-core 0.2.5",
"derive_builder",
"eyre",
"futures",
"genco",
@@ -345,21 +368,69 @@ dependencies = [
]
[[package]]
name = "dagger-sdk"
version = "0.2.0"
name = "darling"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e454c49b81feeb5c4057f54223cb8d7618e5d015ed835c3f3fa231fefa04e833"
checksum = "c0808e1bd8671fb44a113a14e13497557533369847788fa2ae912b6ebfce9fa8"
dependencies = [
"base64",
"dagger-core 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"eyre",
"futures",
"genco",
"gql_client",
"pretty_assertions",
"serde",
"serde_json",
"tokio",
"darling_core",
"darling_macro",
]
[[package]]
name = "darling_core"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "001d80444f28e193f30c2f293455da62dcf9a6b29918a4253152ae2b1de592cb"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim",
"syn",
]
[[package]]
name = "darling_macro"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685"
dependencies = [
"darling_core",
"quote",
"syn",
]
[[package]]
name = "derive_builder"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8"
dependencies = [
"derive_builder_macro",
]
[[package]]
name = "derive_builder_core"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f"
dependencies = [
"darling",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "derive_builder_macro"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e"
dependencies = [
"derive_builder_core",
"syn",
]
[[package]]
@@ -406,9 +477,9 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
[[package]]
name = "encoding_rs"
version = "0.8.31"
version = "0.8.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b"
checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394"
dependencies = [
"cfg-if",
]
@@ -446,23 +517,23 @@ dependencies = [
[[package]]
name = "fastrand"
version = "1.8.0"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499"
checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
dependencies = [
"instant",
]
[[package]]
name = "filetime"
version = "0.2.19"
version = "0.2.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e884668cd0c7480504233e951174ddc3b382f7c2666e3b7310b5c4e7b0c37f9"
checksum = "8a3de6e8d11b22ff9edc6d916f890800597d60f8b2da1caf2955c274638d6412"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"windows-sys 0.42.0",
"windows-sys 0.45.0",
]
[[package]]
@@ -742,9 +813,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "heck"
version = "0.4.0"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
@@ -755,6 +826,12 @@ dependencies = [
"libc",
]
[[package]]
name = "hermit-abi"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
[[package]]
name = "hex"
version = "0.4.3"
@@ -769,9 +846,9 @@ checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0"
[[package]]
name = "http"
version = "0.2.8"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399"
checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482"
dependencies = [
"bytes",
"fnv",
@@ -803,9 +880,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
[[package]]
name = "hyper"
version = "0.14.23"
version = "0.14.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c"
checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c"
dependencies = [
"bytes",
"futures-channel",
@@ -838,6 +915,12 @@ dependencies = [
"tokio-native-tls",
]
[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]]
name = "idna"
version = "0.3.0"
@@ -875,12 +958,12 @@ dependencies = [
[[package]]
name = "io-lifetimes"
version = "1.0.4"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e"
checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3"
dependencies = [
"libc",
"windows-sys 0.42.0",
"windows-sys 0.45.0",
]
[[package]]
@@ -891,14 +974,14 @@ checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146"
[[package]]
name = "is-terminal"
version = "0.4.2"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189"
checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef"
dependencies = [
"hermit-abi",
"hermit-abi 0.3.1",
"io-lifetimes",
"rustix",
"windows-sys 0.42.0",
"windows-sys 0.45.0",
]
[[package]]
@@ -918,9 +1001,9 @@ checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440"
[[package]]
name = "js-sys"
version = "0.3.60"
version = "0.3.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47"
checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730"
dependencies = [
"wasm-bindgen",
]
@@ -996,14 +1079,14 @@ dependencies = [
[[package]]
name = "mio"
version = "0.8.5"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de"
checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9"
dependencies = [
"libc",
"log",
"wasi",
"windows-sys 0.42.0",
"windows-sys 0.45.0",
]
[[package]]
@@ -1030,7 +1113,7 @@ version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b"
dependencies = [
"hermit-abi",
"hermit-abi 0.2.6",
"libc",
]
@@ -1045,9 +1128,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.17.0"
version = "1.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
[[package]]
name = "openssl"
@@ -1192,9 +1275,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.50"
version = "1.0.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2"
checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6"
dependencies = [
"unicode-ident",
]
@@ -1321,16 +1404,16 @@ checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
[[package]]
name = "rustix"
version = "0.36.7"
version = "0.36.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03"
checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644"
dependencies = [
"bitflags",
"errno",
"io-lifetimes",
"libc",
"linux-raw-sys",
"windows-sys 0.42.0",
"windows-sys 0.45.0",
]
[[package]]
@@ -1356,9 +1439,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "security-framework"
version = "2.8.1"
version = "2.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c4437699b6d34972de58652c68b98cb5b53a4199ab126db8e20ec8ded29a721"
checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254"
dependencies = [
"bitflags",
"core-foundation",
@@ -1442,18 +1525,18 @@ dependencies = [
[[package]]
name = "signal-hook-registry"
version = "1.4.0"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0"
checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1"
dependencies = [
"libc",
]
[[package]]
name = "slab"
version = "0.4.7"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef"
checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d"
dependencies = [
"autocfg",
]
@@ -1566,9 +1649,9 @@ dependencies = [
[[package]]
name = "tinyvec_macros"
version = "0.1.0"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
@@ -1603,9 +1686,9 @@ dependencies = [
[[package]]
name = "tokio-native-tls"
version = "0.3.0"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b"
checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
dependencies = [
"native-tls",
"tokio",
@@ -1613,9 +1696,9 @@ dependencies = [
[[package]]
name = "tokio-util"
version = "0.7.4"
version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740"
checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2"
dependencies = [
"bytes",
"futures-core",
@@ -1708,9 +1791,9 @@ dependencies = [
[[package]]
name = "unicode-segmentation"
version = "1.10.0"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a"
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
[[package]]
name = "unreachable"
@@ -1774,9 +1857,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.83"
version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
@@ -1784,9 +1867,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.83"
version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142"
checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9"
dependencies = [
"bumpalo",
"log",
@@ -1799,9 +1882,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.33"
version = "0.4.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d"
checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454"
dependencies = [
"cfg-if",
"js-sys",
@@ -1811,9 +1894,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.83"
version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810"
checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -1821,9 +1904,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.83"
version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6"
dependencies = [
"proc-macro2",
"quote",
@@ -1834,9 +1917,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.83"
version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d"
[[package]]
name = "wasm-streams"
@@ -1853,9 +1936,9 @@ dependencies = [
[[package]]
name = "web-sys"
version = "0.3.60"
version = "0.3.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f"
checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97"
dependencies = [
"js-sys",
"wasm-bindgen",

View File

@@ -1,6 +1,6 @@
[package]
name = "dagger-rs"
version = "0.2.0"
version = "0.2.10"
edition = "2021"
readme = "README.md"
license-file = "LICENSE.MIT"
@@ -19,8 +19,8 @@ members = [
]
[dependencies]
dagger-codegen = { path = "crates/dagger-codegen", version = "0.2.0" }
dagger-core = { path = "crates/dagger-core", version = "0.2.0" }
dagger-codegen = { path = "crates/dagger-codegen", version = "^0.2.5" }
dagger-core = { path = "crates/dagger-core", version = "^0.2.3" }
clap = "4.1.6"
dirs = "4.0.0"
@@ -28,16 +28,15 @@ eyre = "0.6.8"
flate2 = { version = "1.0.25", features = ["zlib"] }
genco = "0.17.3"
graphql-introspection-query = "0.2.0"
graphql_client = { version = "0.12.0", features = [
"reqwest",
"reqwest-blocking",
] }
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", "blocking", "deflate"] }
reqwest = { version = "0.11.14", features = ["stream", "deflate"] }
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.93"
sha2 = "0.10.6"
tar = "0.4.38"
tempfile = "3.3.0"
color-eyre = "0.6.2"
tokio = { version = "1.25.0", features = ["full"] }

View File

@@ -21,10 +21,10 @@ See [dagger-sdk](./crates/dagger-sdk/README.md)
- [x] Context
- [x] Deserializer for nested response (bind)
- [x] Add codegen to hook into querier
- [ ] fix build / release cycle
- [ ] general api stabilisation
- [x] fix build / release cycle
- [x] general api stabilisation
- [x] document usage
- [ ] make async variant
- [x] make async variant
## Architecture

73
ci/CHANGELOG.md Normal file
View File

@@ -0,0 +1,73 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v0.1.0 (2023-02-20)
<csr-id-06e2638e1fec0579d992792b94838629739bb1f0/>
<csr-id-48433cf36884ec9fa4cfed8bc5d4b3e8422c0ab9/>
<csr-id-45d646203704aed317ee2273b825ae708e83ca32/>
<csr-id-c35c104b49dc2f4456ed18e353bf8d4017cff640/>
### Chore
- <csr-id-06e2638e1fec0579d992792b94838629739bb1f0/> with actual await on connect
- <csr-id-48433cf36884ec9fa4cfed8bc5d4b3e8422c0ab9/> with dagger v0.2.10
- <csr-id-45d646203704aed317ee2273b825ae708e83ca32/> with async/await
- <csr-id-c35c104b49dc2f4456ed18e353bf8d4017cff640/> update ci to use dagger-sdk v0.2.6
### Documentation
- <csr-id-30b7511e454d4695cc1106a3d303b20aa8647fe4/> add changelog
### New Features
- <csr-id-691ecfbf52fa24a466d554b7b9701d67c33a42a5/> ci with dagger v0.2.2
- <csr-id-f42da8416a5450c7c3c924353c3cc9112afd18f0/> with sccache
### Bug Fixes
- <csr-id-f40ba9b40312a66b7699209fdddc0153ef139931/> with older version of dagger-sdk
- <csr-id-02006d40fc2c0383e0412c15c36db9af7eda991f/> without phantom data
- <csr-id-199fe16dbf426f287a7a5237c25bc16a4cae49bc/> update rust crate dagger-sdk to 0.2.1
- <csr-id-25fb9d4f24af8e7d6d81463c19a07a718b8a312a/> with secret
- <csr-id-d72313051b9b46a6eeaa909a11850b3d8fc75e81/> with test changes
### Commit Statistics
<csr-read-only-do-not-edit/>
- 16 commits contributed to the release over the course of 2 calendar days.
- 12 commits were understood as [conventional](https://www.conventionalcommits.org).
- 2 unique issues were worked on: [#7](https://github.com/kjuulh/dagger-rs/issues/7), [#8](https://github.com/kjuulh/dagger-rs/issues/8)
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **[#7](https://github.com/kjuulh/dagger-rs/issues/7)**
- add ci ([`4ce58a4`](https://github.com/kjuulh/dagger-rs/commit/4ce58a418c0ccef6cc0bfbaa878453f03c02dffb))
* **[#8](https://github.com/kjuulh/dagger-rs/issues/8)**
- feature with workspace ([`03e022f`](https://github.com/kjuulh/dagger-rs/commit/03e022fcaccd30ef0566dcfe31beb3473706bd1d))
* **Uncategorized**
- add changelog ([`30b7511`](https://github.com/kjuulh/dagger-rs/commit/30b7511e454d4695cc1106a3d303b20aa8647fe4))
- with actual await on connect ([`06e2638`](https://github.com/kjuulh/dagger-rs/commit/06e2638e1fec0579d992792b94838629739bb1f0))
- with dagger v0.2.10 ([`48433cf`](https://github.com/kjuulh/dagger-rs/commit/48433cf36884ec9fa4cfed8bc5d4b3e8422c0ab9))
- with older version of dagger-sdk ([`f40ba9b`](https://github.com/kjuulh/dagger-rs/commit/f40ba9b40312a66b7699209fdddc0153ef139931))
- with async/await ([`45d6462`](https://github.com/kjuulh/dagger-rs/commit/45d646203704aed317ee2273b825ae708e83ca32))
- update ci to use dagger-sdk v0.2.6 ([`c35c104`](https://github.com/kjuulh/dagger-rs/commit/c35c104b49dc2f4456ed18e353bf8d4017cff640))
- without phantom data ([`02006d4`](https://github.com/kjuulh/dagger-rs/commit/02006d40fc2c0383e0412c15c36db9af7eda991f))
- ci with dagger v0.2.2 ([`691ecfb`](https://github.com/kjuulh/dagger-rs/commit/691ecfbf52fa24a466d554b7b9701d67c33a42a5))
- with bin cache ([`3cb83bb`](https://github.com/kjuulh/dagger-rs/commit/3cb83bb79ceda52a0bf459850252e3902b7352fa))
- update rust crate dagger-sdk to 0.2.1 ([`199fe16`](https://github.com/kjuulh/dagger-rs/commit/199fe16dbf426f287a7a5237c25bc16a4cae49bc))
- with secret ([`25fb9d4`](https://github.com/kjuulh/dagger-rs/commit/25fb9d4f24af8e7d6d81463c19a07a718b8a312a))
- with sccache ([`f42da84`](https://github.com/kjuulh/dagger-rs/commit/f42da8416a5450c7c3c924353c3cc9112afd18f0))
- with test changes ([`d723130`](https://github.com/kjuulh/dagger-rs/commit/d72313051b9b46a6eeaa909a11850b3d8fc75e81))
- add ci ([`468bca4`](https://github.com/kjuulh/dagger-rs/commit/468bca4a69ec321b3ae1304d29d1be66a921a7db))
</details>

View File

@@ -8,5 +8,6 @@ edition = "2021"
[dependencies]
clap = "4.1.6"
color-eyre = "0.6.2"
dagger-sdk = "0.2.0"
dagger-sdk = "0.2.11"
eyre = "0.6.8"
tokio = { version = "1.25.0", features = ["full"] }

View File

@@ -1,21 +1,25 @@
use std::sync::Arc;
use dagger_sdk::gen::{Container, HostDirectoryOpts, Query};
use dagger_sdk::{Container, HostDirectoryOpts, Query};
fn main() -> eyre::Result<()> {
#[tokio::main]
async fn main() -> eyre::Result<()> {
color_eyre::install().unwrap();
let matches = clap::Command::new("ci")
.subcommand_required(true)
.subcommand(clap::Command::new("pr"))
.subcommand(clap::Command::new("release"))
.get_matches();
let client = dagger_sdk::client::connect()?;
let base = select_base_image(client.clone());
let client = dagger_sdk::connect().await?;
match matches.subcommand() {
Some(("pr", _)) => return validate_pr(client, base),
Some(("pr", _)) => {
let base = select_base_image(client.clone()).await?;
return validate_pr(client, base).await;
}
Some(("release", subm)) => return release(client, subm).await,
Some(_) => {
panic!("invalid subcommand selected!")
}
@@ -25,97 +29,146 @@ fn main() -> eyre::Result<()> {
}
}
fn get_dependencies(client: Arc<Query>) -> Container {
let cargo_dir = client.host().directory(
".".into(),
Some(HostDirectoryOpts {
exclude: None,
include: Some(vec![
"**/Cargo.lock".into(),
"**/Cargo.toml".into(),
"**/main.rs".into(),
"**/lib.rs".into(),
]),
}),
);
let src_dir = client.host().directory(
".".into(),
Some(HostDirectoryOpts {
exclude: Some(vec!["target/".into()]),
async fn release(client: Arc<Query>, _subm: &clap::ArgMatches) -> Result<(), color_eyre::Report> {
let src_dir = client.host().directory_opts(
".",
HostDirectoryOpts {
exclude: Some(vec!["target/"]),
include: None,
}),
},
);
let cache_cargo_index_dir = client.cache_volume("cargo_index".into());
let cache_cargo_deps = client.cache_volume("cargo_deps".into());
let base_image = client
.container(None)
.from("rust:latest".into())
.with_workdir("app".into())
.with_exec(
vec!["cargo".into(), "install".into(), "cargo-chef".into()],
None,
);
.container()
.from("rust:latest")
.with_workdir("app")
.with_mounted_directory("/app/", src_dir.id().await?);
let recipe = base_image
.with_mounted_directory(".".into(), cargo_dir.id())
.with_mounted_cache(
"~/.cargo/.package-cache".into(),
cache_cargo_index_dir.id(),
None,
)
.with_exec(
vec![
"cargo".into(),
"chef".into(),
"prepare".into(),
"--recipe-path".into(),
"recipe.json".into(),
],
None,
)
.file("/app/recipe.json".into());
let container = base_image
.with_exec(vec!["cargo", "install", "cargo-smart-release"])
.with_exec(vec![
"cargo",
"smart-release",
"--execute",
"--allow-fully-generated-changelogs",
"--no-changelog-preview",
"dagger-rs",
"dagger-sdk",
]);
let exit = container.exit_code().await?;
if exit != 0 {
eyre::bail!("container failed with non-zero exit code");
}
let builder_start = base_image
.with_mounted_file("/app/recipe.json".into(), recipe.id())
.with_exec(
vec![
"cargo".into(),
"chef".into(),
"cook".into(),
"--release".into(),
"--recipe-path".into(),
"recipe.json".into(),
],
None,
)
.with_mounted_cache("/app/".into(), cache_cargo_deps.id(), None)
.with_mounted_directory("/app/".into(), src_dir.id())
.with_exec(
vec![
"cargo".into(),
"build".into(),
"--all".into(),
"--release".into(),
],
None,
);
println!("released pr succeeded!");
return builder_start;
Ok(())
}
fn select_base_image(client: Arc<Query>) -> Container {
let src_dir = get_dependencies(client.clone());
async fn get_dependencies(client: Arc<Query>) -> eyre::Result<Container> {
let cargo_dir = client.host().directory_opts(
".",
HostDirectoryOpts {
exclude: None,
include: Some(vec![
"**/Cargo.lock",
"**/Cargo.toml",
"**/main.rs",
"**/lib.rs",
]),
},
);
let src_dir = client.host().directory_opts(
".",
HostDirectoryOpts {
exclude: Some(vec!["target/"]),
include: None,
},
);
let cache_cargo_index_dir = client.cache_volume("cargo_index");
let cache_cargo_deps = client.cache_volume("cargo_deps");
let cache_cargo_bin = client.cache_volume("cargo_bin_cache");
let minio_url = "https://github.com/mozilla/sccache/releases/download/v0.3.3/sccache-v0.3.3-x86_64-unknown-linux-musl.tar.gz";
let base_image = client
.container()
.from("rust:latest")
.with_workdir("app")
.with_exec(vec!["apt-get", "update"])
.with_exec(vec!["apt-get", "install", "--yes", "libpq-dev", "wget"])
.with_exec(vec!["wget", minio_url])
.with_exec(vec![
"tar",
"xzf",
"sccache-v0.3.3-x86_64-unknown-linux-musl.tar.gz",
])
.with_exec(vec![
"mv",
"sccache-v0.3.3-x86_64-unknown-linux-musl/sccache",
"/usr/local/bin/sccache",
])
.with_exec(vec!["chmod", "+x", "/usr/local/bin/sccache"])
.with_env_variable("RUSTC_WRAPPER", "/usr/local/bin/sccache")
.with_env_variable(
"AWS_ACCESS_KEY_ID",
std::env::var("AWS_ACCESS_KEY_ID").unwrap_or("".into()),
)
.with_env_variable(
"AWS_SECRET_ACCESS_KEY",
std::env::var("AWS_SECRET_ACCESS_KEY").unwrap_or("".into()),
)
.with_env_variable("SCCACHE_BUCKET", "sccache")
.with_env_variable("SCCACHE_REGION", "auto")
.with_env_variable("SCCACHE_ENDPOINT", "https://api-minio.front.kjuulh.io")
.with_mounted_cache("~/.cargo/bin", cache_cargo_bin.id().await?)
.with_mounted_cache("~/.cargo/registry/index", cache_cargo_bin.id().await?)
.with_mounted_cache("~/.cargo/registry/cache", cache_cargo_bin.id().await?)
.with_mounted_cache("~/.cargo/git/db", cache_cargo_bin.id().await?)
.with_mounted_cache("target/", cache_cargo_bin.id().await?)
.with_exec(vec!["cargo", "install", "cargo-chef"]);
let recipe = base_image
.with_mounted_directory(".", cargo_dir.id().await?)
.with_mounted_cache("~/.cargo/.package-cache", cache_cargo_index_dir.id().await?)
.with_exec(vec![
"cargo",
"chef",
"prepare",
"--recipe-path",
"recipe.json",
])
.file("/app/recipe.json");
let builder_start = base_image
.with_mounted_file("/app/recipe.json", recipe.id().await?)
.with_exec(vec![
"cargo",
"chef",
"cook",
"--release",
"--workspace",
"--recipe-path",
"recipe.json",
])
.with_mounted_cache("/app/", cache_cargo_deps.id().await?)
.with_mounted_directory("/app/", src_dir.id().await?)
.with_exec(vec!["cargo", "build", "--all", "--release"]);
return Ok(builder_start);
}
async fn select_base_image(client: Arc<Query>) -> eyre::Result<Container> {
let src_dir = get_dependencies(client.clone()).await;
src_dir
}
fn validate_pr(_client: Arc<Query>, container: Container) -> eyre::Result<()> {
//let container = container.with_exec(vec!["cargo".into(), "test".into(), "--all".into()], None);
async fn validate_pr(_client: Arc<Query>, container: Container) -> eyre::Result<()> {
//let container = container.with_exec(vec!["cargo", "test", "--all"], None);
let exit = container.exit_code();
let exit = container.exit_code().await?;
if exit != 0 {
eyre::bail!("container failed with non-zero exit code");
}

View File

@@ -0,0 +1,290 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v0.2.7 (2023-02-20)
### Bug Fixes
- <csr-id-a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de/> race condition in process
### Commit Statistics
<csr-read-only-do-not-edit/>
- 1 commit contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- race condition in process ([`a13a2a9`](https://github.com/kjuulh/dagger-rs/commit/a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de))
</details>
## v0.2.6 (2023-02-20)
<csr-id-803cfc4f8c4d72ab7d011be5523b3bfc6039de39/>
### Chore
- <csr-id-803cfc4f8c4d72ab7d011be5523b3bfc6039de39/> ran clippy
### Commit Statistics
<csr-read-only-do-not-edit/>
- 3 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`f869e57`](https://github.com/kjuulh/dagger-rs/commit/f869e574dd788cd60e5b1b5d502bec68e300694c))
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`17ec62a`](https://github.com/kjuulh/dagger-rs/commit/17ec62a5d58232ff57391523b9851fb7b07d02ab))
- ran clippy ([`803cfc4`](https://github.com/kjuulh/dagger-rs/commit/803cfc4f8c4d72ab7d011be5523b3bfc6039de39))
</details>
## v0.2.5 (2023-02-19)
### New Features
- <csr-id-978ede68ae52f5b5150a2aa45b8d6e1fbbbee2f4/> add documentation strings
- <csr-id-9be6f435d9ea39f31a8906e55dbd3e8b1e5ec598/> Use async runtime instead of blocking.
Default to using async runtime instead of blocking. I.e.
```rust
fn main() -> eyre::Result<()> {
// ...
client.container().from("rust").publish("somewhere")?;
// ...
}
// to
async fn main() -> eyre::Result<()> {
// ...
client.container().from("rust").publish("somewhere").await?;
// ...
}
```
### Commit Statistics
<csr-read-only-do-not-edit/>
- 3 commits contributed to the release.
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-sdk v0.2.8, dagger-codegen v0.2.5 ([`0499024`](https://github.com/kjuulh/dagger-rs/commit/04990247ba8e9d0555847f582fef14849dbedebf))
- add documentation strings ([`978ede6`](https://github.com/kjuulh/dagger-rs/commit/978ede68ae52f5b5150a2aa45b8d6e1fbbbee2f4))
- Use async runtime instead of blocking. ([`9be6f43`](https://github.com/kjuulh/dagger-rs/commit/9be6f435d9ea39f31a8906e55dbd3e8b1e5ec598))
</details>
## v0.2.4 (2023-02-19)
### New Features
- <csr-id-f29ff836cfd72d5e051ca6a71a230ba1e9933091/> without Some in _opts functions
Option has been removed as a wrapper around opts. This makes it much
more convenient to use
```rust
client.container_opts(Some(ContainerOpts{}))
// ->
client.container_opts(ContainerOpts{})
```
The same options are still available, either an empty object can be
passed, or a non _opts function can be used
- <csr-id-9762da895a164e30c5dc60e89a83e934ceae47ab/> with _opts methods
Now all opt values enter into a _opts function instead of the original.
This avoids a lot of verbosity for both None in the case opts are
unwanted, and Some() if they actually are.
They are used like so:
```rust
client.container().from("...");
client.container_opts(Some(ContainerOpts{ ... }))
```
Some from opts will be removed in a future commit/pr
- <csr-id-94336d06378f035464e233b921dc3858070f582d/> move to &str instead of String and introduce builder.
This will make the api much easier to use, as we can now rely on ""
instead of "".into() for normal string values.
Introduced builder as well, which makes it much easier to use *Opts, as
it can handle the building of that, and get the benefits from String ->
&str, as that is currently not allowed for optional values
### Bug Fixes
- <csr-id-c627595fd2695e236924175d137c42f1480ccd6b/> cargo clippy
- <csr-id-02006d40fc2c0383e0412c15c36db9af7eda991f/> without phantom data
### Commit Statistics
<csr-read-only-do-not-edit/>
- 6 commits contributed to the release.
- 5 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-sdk v0.2.5, dagger-codegen v0.2.4 ([`f727318`](https://github.com/kjuulh/dagger-rs/commit/f72731807d8358fdb3d80432136b7a08bb7b1773))
- cargo clippy ([`c627595`](https://github.com/kjuulh/dagger-rs/commit/c627595fd2695e236924175d137c42f1480ccd6b))
- without Some in _opts functions ([`f29ff83`](https://github.com/kjuulh/dagger-rs/commit/f29ff836cfd72d5e051ca6a71a230ba1e9933091))
- with _opts methods ([`9762da8`](https://github.com/kjuulh/dagger-rs/commit/9762da895a164e30c5dc60e89a83e934ceae47ab))
- without phantom data ([`02006d4`](https://github.com/kjuulh/dagger-rs/commit/02006d40fc2c0383e0412c15c36db9af7eda991f))
- move to &str instead of String and introduce builder. ([`94336d0`](https://github.com/kjuulh/dagger-rs/commit/94336d06378f035464e233b921dc3858070f582d))
</details>
## v0.2.3 (2023-02-19)
### New Features
- <csr-id-de063eae858eb3335d2558a57ee6a88689635200/> with return result instead of unwrap
- <csr-id-5d667369900a47d3a6015cd3814c240bc5c54436/> remove unnecessary option returns
### Commit Statistics
<csr-read-only-do-not-edit/>
- 3 commits contributed to the release.
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-sdk v0.2.3, dagger-codegen v0.2.3, dagger-rs v0.2.9 ([`9235030`](https://github.com/kjuulh/dagger-rs/commit/92350306b3f0da40b4fc6dcaffcd90b891e83f70))
- with return result instead of unwrap ([`de063ea`](https://github.com/kjuulh/dagger-rs/commit/de063eae858eb3335d2558a57ee6a88689635200))
- remove unnecessary option returns ([`5d66736`](https://github.com/kjuulh/dagger-rs/commit/5d667369900a47d3a6015cd3814c240bc5c54436))
</details>
## v0.2.2 (2023-02-19)
### New Features
- <csr-id-6e5f4074329ab0462445b31d4153f8497c483438/> update to dagger v0.3.12
### Commit Statistics
<csr-read-only-do-not-edit/>
- 2 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.2, dagger-codegen v0.2.2, dagger-rs v0.2.8 ([`1638f15`](https://github.com/kjuulh/dagger-rs/commit/1638f15fba9d16512e8452f87b908d6dce417cd9))
- update to dagger v0.3.12 ([`6e5f407`](https://github.com/kjuulh/dagger-rs/commit/6e5f4074329ab0462445b31d4153f8497c483438))
</details>
## v0.2.1 (2023-02-18)
<csr-id-6afe141d34308f18f9d46419931d2c9b822a7aef/>
### Bug Fixes
- <csr-id-789b0e69c8c53d0e86d9cec89ab5345507aad514/> update all dependencies
### Other
- <csr-id-6afe141d34308f18f9d46419931d2c9b822a7aef/> fix
### Commit Statistics
<csr-read-only-do-not-edit/>
- 35 commits contributed to the release over the course of 20 calendar days.
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
- 2 unique issues were worked on: [#5](https://github.com/kjuulh/dagger-rs/issues/5), [#6](https://github.com/kjuulh/dagger-rs/issues/6)
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **[#5](https://github.com/kjuulh/dagger-rs/issues/5)**
- update all dependencies ([`789b0e6`](https://github.com/kjuulh/dagger-rs/commit/789b0e69c8c53d0e86d9cec89ab5345507aad514))
* **[#6](https://github.com/kjuulh/dagger-rs/issues/6)**
- feature/add impl ([`4a4c03f`](https://github.com/kjuulh/dagger-rs/commit/4a4c03f3c2ee7f6268c65976715e70767b4ea78d))
* **Uncategorized**
- Release dagger-core v0.2.1, dagger-codegen v0.2.1, dagger-rs v0.2.1 ([`1332bc8`](https://github.com/kjuulh/dagger-rs/commit/1332bc842ce2ea0254c651419813b63b36ca590c))
- add changelogs ([`a064684`](https://github.com/kjuulh/dagger-rs/commit/a064684fcf80196188a57d9ff9067c0b5769fb09))
- Adjusting changelogs prior to release of dagger-core v0.2.1, dagger-codegen v0.2.1, dagger-rs v0.2.1 ([`f4a20fd`](https://github.com/kjuulh/dagger-rs/commit/f4a20fda79063b29829cc899793775ba8cb17214))
- remove toolchain ([`f034528`](https://github.com/kjuulh/dagger-rs/commit/f03452840cf9260cd1d5e5aa8d7ee2897384c745))
- with actual versions ([`7153c24`](https://github.com/kjuulh/dagger-rs/commit/7153c24f0105a05f170efd10ef2535d83ce0c87e))
- with publish ([`989d5bc`](https://github.com/kjuulh/dagger-rs/commit/989d5bc26036d46a199d939b5cbbe72aff2f8fb1))
- codegen also with repository ([`c625ae4`](https://github.com/kjuulh/dagger-rs/commit/c625ae49ba4d2112ea9d4907a6689fd8e74b808c))
- with readme and license ([`1e26b38`](https://github.com/kjuulh/dagger-rs/commit/1e26b383d4f6dbcbe20f5f7c19c749e743f6e607))
- with wildcard version ([`533b9df`](https://github.com/kjuulh/dagger-rs/commit/533b9dfef0165c514127a8437d08daf52adf5739))
- cargo version 0.2.0 ([`bec62de`](https://github.com/kjuulh/dagger-rs/commit/bec62de62ff5638428174e232a36eee3ddd0f5ef))
- bump version ([`36b0ecd`](https://github.com/kjuulh/dagger-rs/commit/36b0ecdabf4c220cffb2d0660fb6480387e3249a))
- fix all clippy ([`6be8482`](https://github.com/kjuulh/dagger-rs/commit/6be8482b461e098384bbf1371ed7d67b259197fa))
- fmt tests ([`2eb0277`](https://github.com/kjuulh/dagger-rs/commit/2eb027754b357100544fe0c8f7c5f6125e017c6f))
- add tests ([`19b46b6`](https://github.com/kjuulh/dagger-rs/commit/19b46b6cf04ff3cff49047699dea20ca784c5536))
- pull out args wip ([`c4edd29`](https://github.com/kjuulh/dagger-rs/commit/c4edd29f50b6ada2cc3afd2f4df2ec47920c4607))
- implement sort by name and type ([`d9b51c1`](https://github.com/kjuulh/dagger-rs/commit/d9b51c1ac90c00fb3af24332b6140e1201bc9be7))
- fix optional types for real ([`26069a8`](https://github.com/kjuulh/dagger-rs/commit/26069a82a69ec7265216c8ddaceb37228dd0fb81))
- fix description ([`f4581ba`](https://github.com/kjuulh/dagger-rs/commit/f4581ba4cd1693a906eaf6c58054398ceae3bfac))
- with proper optional types ([`f4a812a`](https://github.com/kjuulh/dagger-rs/commit/f4a812a7d24e9e09cb4e3cbde56ee0b3ac774b62))
- set proper option type ([`8549cfc`](https://github.com/kjuulh/dagger-rs/commit/8549cfc3a7d9f831febaeadc22db36604e465ea8))
- add fields ([`496a687`](https://github.com/kjuulh/dagger-rs/commit/496a687bc34f7c58cc86df60c183be741b0b8a9c))
- add input_fields ([`d2cddff`](https://github.com/kjuulh/dagger-rs/commit/d2cddff365c636feceb3f20a73df812fcab11a19))
- with objects ([`5fef514`](https://github.com/kjuulh/dagger-rs/commit/5fef5148010f384d0158361d64b8e17d357d4819))
- remove hardcoded test ([`910ff4a`](https://github.com/kjuulh/dagger-rs/commit/910ff4a72e10f5384287fed35f56bc7f662e7ccd))
- fix ([`6afe141`](https://github.com/kjuulh/dagger-rs/commit/6afe141d34308f18f9d46419931d2c9b822a7aef))
- formatting ([`3a7ee33`](https://github.com/kjuulh/dagger-rs/commit/3a7ee33e1ed317288b2022ea5a4ce721d59fb11e))
- remove dummy string ([`e7f6560`](https://github.com/kjuulh/dagger-rs/commit/e7f6560247768afbca0c350df7d4ccf3909b74fa))
- with input objects ([`dc53fc1`](https://github.com/kjuulh/dagger-rs/commit/dc53fc1d474b549bb1c580865a049e2fac2f5e6d))
- with enum ([`2a1f7c3`](https://github.com/kjuulh/dagger-rs/commit/2a1f7c3f2666f1f4caebf7c22707709741c2cfad))
- with codegen output ([`0bf6b0e`](https://github.com/kjuulh/dagger-rs/commit/0bf6b0e91ecc31c1f6b51338234137eb185810a0))
- added scalars ([`e587414`](https://github.com/kjuulh/dagger-rs/commit/e5874141b3b6256b7ac2a0bf653089fa7bcc5d14))
- with scalars ([`0d6e6e5`](https://github.com/kjuulh/dagger-rs/commit/0d6e6e57ae6a3b8a1f450d719c9973130af873b7))
- split out codegen parts ([`3263f1d`](https://github.com/kjuulh/dagger-rs/commit/3263f1d589aee78065401c666533cb0cbadd06ce))
</details>

View File

@@ -1,6 +1,6 @@
[package]
name = "dagger-codegen"
version = "0.2.0"
version = "0.2.7"
edition = "2021"
readme = "README.md"
license-file = "LICENSE.MIT"
@@ -11,7 +11,7 @@ publish = true
[dependencies]
convert_case = "0.6.0"
dagger-core = { path = "../dagger-core", version = "0.2.0" }
dagger-core = { path = "../dagger-core", version = "^0.2.5" }
eyre = "0.6.8"
genco = "0.17.3"

View File

@@ -6,8 +6,8 @@ use eyre::ContextCompat;
use crate::utility::OptionExt;
pub trait FormatTypeFuncs {
fn format_kind_list(&self, representation: &str) -> String;
fn format_kind_scalar_string(&self, representation: &str) -> String;
fn format_kind_list(&self, representation: &str, input: bool, immutable: bool) -> String;
fn format_kind_scalar_string(&self, representation: &str, input: bool) -> String;
fn format_kind_scalar_int(&self, representation: &str) -> String;
fn format_kind_scalar_float(&self, representation: &str) -> String;
fn format_kind_scalar_boolean(&self, representation: &str) -> String;
@@ -36,14 +36,18 @@ impl CommonFunctions {
}
pub fn format_input_type(&self, t: &TypeRef) -> String {
self.format_type(t, true)
self.format_type(t, true, false)
}
pub fn format_output_type(&self, t: &TypeRef) -> String {
self.format_type(t, false)
self.format_type(t, false, false)
}
fn format_type(&self, t: &TypeRef, input: bool) -> String {
pub fn format_immutable_input_type(&self, t: &TypeRef) -> String {
self.format_type(t, true, true)
}
fn format_type(&self, t: &TypeRef, input: bool, immutable: bool) -> String {
let mut representation = String::new();
let mut r = Some(t.clone());
while r.is_some() {
@@ -57,9 +61,14 @@ impl CommonFunctions {
Scalar::Float => self
.format_type_funcs
.format_kind_scalar_float(&mut representation),
Scalar::String => self
.format_type_funcs
.format_kind_scalar_string(&mut representation),
Scalar::String => {
if immutable {
"&'a str".into()
} else {
self.format_type_funcs
.format_kind_scalar_string(&mut representation, input)
}
}
Scalar::Boolean => self
.format_type_funcs
.format_kind_scalar_boolean(&mut representation),
@@ -87,12 +96,15 @@ impl CommonFunctions {
.as_ref()
.map(|t| t.clone())
.map(|t| *t)
.map(|t| self.format_type(&t, input))
.map(|t| self.format_type(&t, input, immutable))
.context("could not get inner type of list")
.unwrap();
representation =
self.format_type_funcs.format_kind_list(&mut inner_type);
representation = self.format_type_funcs.format_kind_list(
&mut inner_type,
input,
immutable,
);
return representation;
}

View File

@@ -5,13 +5,17 @@ use super::functions::format_name;
pub struct FormatTypeFunc;
impl FormatTypeFuncs for FormatTypeFunc {
fn format_kind_list(&self, representation: &str) -> String {
fn format_kind_list(&self, representation: &str, _input: bool, _immutable: bool) -> String {
format!("Vec<{}>", representation)
}
fn format_kind_scalar_string(&self, representation: &str) -> String {
fn format_kind_scalar_string(&self, representation: &str, input: bool) -> String {
let mut rep = representation.to_string();
rep.push_str("String");
if input {
rep.push_str("impl Into<String>");
} else {
rep.push_str("String");
}
rep
}

View File

@@ -1,15 +1,17 @@
use convert_case::{Case, Casing};
use dagger_core::introspection::FullTypeFields;
use dagger_core::introspection::{FullTypeFields, TypeRef};
use genco::prelude::rust;
use genco::quote;
use genco::tokens::quoted;
use crate::functions::{
type_field_has_optional, type_ref_is_list_of_objects, type_ref_is_object,
type_ref_is_optional, CommonFunctions,
type_field_has_optional, type_ref_is_list, type_ref_is_list_of_objects, type_ref_is_object,
type_ref_is_optional, type_ref_is_scalar, CommonFunctions, Scalar,
};
use crate::utility::OptionExt;
use super::templates::object_tmpl::render_optional_field_args;
pub fn format_name(s: &str) -> String {
s.to_case(Case::Pascal)
}
@@ -29,28 +31,83 @@ pub fn field_options_struct_name(field: &FullTypeFields) -> Option<String> {
}
pub fn format_function(funcs: &CommonFunctions, field: &FullTypeFields) -> Option<rust::Tokens> {
let is_async = field.type_.pipe(|t| &t.type_ref).pipe(|t| {
if type_ref_is_object(&t) || type_ref_is_list_of_objects(&t) {
return None;
} else {
return Some(quote! {
async
});
};
});
let signature = quote! {
pub fn $(field.name.pipe(|n | format_struct_name(n)))
pub $(is_async) fn $(field.name.pipe(|n | format_struct_name(n)))
};
let args = format_function_args(funcs, field);
let lifecycle = format_optional_args(funcs, field)
.pipe(|(_, contains_lifecycle)| contains_lifecycle)
.and_then(|c| {
if *c {
Some(quote! {
<'a>
})
} else {
None
}
});
let args = format_function_args(funcs, field, lifecycle.as_ref());
let output_type = field
.type_
.pipe(|t| &t.type_ref)
.pipe(|t| funcs.format_output_type(t));
.pipe(|t| render_output_type(funcs, t));
Some(quote! {
$(signature)(
$(args)
) -> $(output_type) {
let mut query = self.selection.select($(quoted(field.name.as_ref())));
if let Some((args, desc, true)) = args {
let required_args = format_required_function_args(funcs, field);
Some(quote! {
$(field.description.pipe(|d| format_struct_comment(d)))
$(&desc)
$(&signature)(
$(required_args)
) -> $(output_type.as_ref()) {
let mut query = self.selection.select($(quoted(field.name.as_ref())));
$(render_required_args(funcs, field))
$(render_optional_args(funcs, field))
$(render_required_args(funcs, field))
$(render_execution(funcs, field))
}
})
$(render_execution(funcs, field))
}
$(field.description.pipe(|d| format_struct_comment(d)))
$(&desc)
$(&signature)_opts$(lifecycle)(
$args
) -> $(output_type) {
let mut query = self.selection.select($(quoted(field.name.as_ref())));
$(render_required_args(funcs, field))
$(render_optional_args(funcs, field))
$(render_execution(funcs, field))
}
})
} else {
Some(quote! {
$(field.description.pipe(|d| format_struct_comment(d)))
$(if let Some((_, desc, _)) = &args => $desc)
$(signature)(
$(if let Some((args, _, _)) = &args => $args)
) -> $(output_type) {
let mut query = self.selection.select($(quoted(field.name.as_ref())));
$(render_required_args(funcs, field))
$(render_optional_args(funcs, field))
$(render_execution(funcs, field))
}
})
}
}
fn render_required_args(_funcs: &CommonFunctions, field: &FullTypeFields) -> Option<rust::Tokens> {
@@ -66,8 +123,42 @@ fn render_required_args(_funcs: &CommonFunctions, field: &FullTypeFields) -> Opt
let n = format_struct_name(&s.input_value.name);
let name = &s.input_value.name;
if type_ref_is_scalar(&s.input_value.type_) {
if let Scalar::String =
Scalar::from(&*s.input_value.type_.of_type.as_ref().unwrap().clone())
{
return Some(quote! {
query = query.arg($(quoted(name)), $(&n).into());
});
}
}
if type_ref_is_list(&s.input_value.type_) {
let inner = *s
.input_value
.type_
.of_type
.as_ref()
.unwrap()
.clone()
.of_type
.as_ref()
.unwrap()
.clone();
println!("type: {:?}", inner);
if type_ref_is_scalar(&inner) {
if let Scalar::String =
Scalar::from(&*inner.of_type.as_ref().unwrap().clone())
{
return Some(quote! {
query = query.arg($(quoted(name)), $(&n).into_iter().map(|i| i.into()).collect::<Vec<String>>());
});
}
}
}
Some(quote! {
query = query.arg($(quoted(name)), $(n)).unwrap();
query = query.arg($(quoted(name)), $(n));
})
})
})
@@ -98,7 +189,7 @@ fn render_optional_args(_funcs: &CommonFunctions, field: &FullTypeFields) -> Opt
Some(quote! {
if let Some($(&n)) = opts.$(&n) {
query = query.arg($(quoted(name)), $(&n)).unwrap();
query = query.arg($(quoted(name)), $(&n));
}
})
})
@@ -111,9 +202,7 @@ fn render_optional_args(_funcs: &CommonFunctions, field: &FullTypeFields) -> Opt
}
let required_args = quote! {
if let Some(opts) = opts {
$(for arg in args join ($['\r']) => $arg)
}
$(for arg in args join ($['\r']) => $arg)
};
Some(required_args)
@@ -122,6 +211,20 @@ fn render_optional_args(_funcs: &CommonFunctions, field: &FullTypeFields) -> Opt
}
}
fn render_output_type(funcs: &CommonFunctions, type_ref: &TypeRef) -> rust::Tokens {
let output_type = funcs.format_output_type(type_ref);
if type_ref_is_object(type_ref) || type_ref_is_list_of_objects(type_ref) {
return quote! {
$(output_type)
};
}
quote! {
eyre::Result<$output_type>
}
}
fn render_execution(funcs: &CommonFunctions, field: &FullTypeFields) -> rust::Tokens {
if let Some(true) = field.type_.pipe(|t| type_ref_is_object(&t.type_ref)) {
let output_type = funcs.format_output_type(&field.type_.as_ref().unwrap().type_ref);
@@ -163,11 +266,91 @@ fn render_execution(funcs: &CommonFunctions, field: &FullTypeFields) -> rust::To
let graphql_client = rust::import("crate::client", "graphql_client");
quote! {
query.execute(&$graphql_client(&self.conn)).unwrap().unwrap()
query.execute(&$graphql_client(&self.conn)).await
}
}
fn format_function_args(funcs: &CommonFunctions, field: &FullTypeFields) -> Option<rust::Tokens> {
fn format_function_args(
funcs: &CommonFunctions,
field: &FullTypeFields,
lifecycle: Option<&rust::Tokens>,
) -> Option<(rust::Tokens, rust::Tokens, bool)> {
let mut argument_description = Vec::new();
if let Some(args) = field.args.as_ref() {
let args = args
.into_iter()
.map(|a| {
a.as_ref().and_then(|s| {
if type_ref_is_optional(&s.input_value.type_) {
return None;
}
let t = funcs.format_input_type(&s.input_value.type_);
let n = format_struct_name(&s.input_value.name);
if let Some(desc) = s.input_value.description.as_ref().and_then(|d| {
if d != "" {
Some(write_comment_line(&format!("* `{n}` - {}", d)))
} else {
None
}
}) {
argument_description.push(quote! {
$(desc)
});
}
Some(quote! {
$(n): $(t),
})
})
})
.flatten()
.collect::<Vec<_>>();
let required_args = quote! {
&self,
$(for arg in args join ($['\r']) => $arg)
};
if type_field_has_optional(field) {
let field_name = field_options_struct_name(field);
argument_description.push(quote! {
$(field_name.pipe(|_| write_comment_line(&format!("* `opt` - optional argument, see inner type for documentation, use <func>_opts to use"))))
});
let description = quote! {
$(if argument_description.len() > 0 => $(format!("/// ")))
$(if argument_description.len() > 0 => $(format!("/// # Arguments")))
$(if argument_description.len() > 0 => $(format!("/// ")))
$(for arg_desc in argument_description join ($['\r']) => $arg_desc)
};
Some((
quote! {
$(required_args)
opts: $(field_name)$(lifecycle)
},
description,
true,
))
} else {
let description = quote! {
$(if argument_description.len() > 0 => $(format!("/// ")))
$(if argument_description.len() > 0 => $(format!("/// # Arguments")))
$(if argument_description.len() > 0 => $(format!("/// ")))
$(for arg_desc in argument_description join ($['\r']) => $arg_desc)
};
Some((required_args, description, false))
}
} else {
None
}
}
fn format_required_function_args(
funcs: &CommonFunctions,
field: &FullTypeFields,
) -> Option<rust::Tokens> {
if let Some(args) = field.args.as_ref() {
let args = args
.into_iter()
@@ -192,14 +375,56 @@ fn format_function_args(funcs: &CommonFunctions, field: &FullTypeFields) -> Opti
$(for arg in args join ($['\r']) => $arg)
};
if type_field_has_optional(field) {
Some(quote! {
$(required_args)
opts: Option<$(field_options_struct_name(field))>
})
} else {
Some(required_args)
}
Some(required_args)
} else {
None
}
}
pub fn format_optional_args(
funcs: &CommonFunctions,
field: &FullTypeFields,
) -> Option<(rust::Tokens, bool)> {
field
.args
.pipe(|t| t.into_iter().flatten().collect::<Vec<_>>())
.map(|t| {
t.into_iter()
.filter(|t| type_ref_is_optional(&t.input_value.type_))
.collect::<Vec<_>>()
})
.pipe(|t| render_optional_field_args(funcs, t))
.flatten()
}
pub fn write_comment_line(content: &str) -> Option<rust::Tokens> {
let cnt = content.trim();
if cnt == "" {
return None;
}
let mut tokens = rust::Tokens::new();
for line in content.split('\n') {
tokens.append(format!("/// {}", line.trim()));
tokens.push();
}
Some(tokens)
}
pub fn format_struct_comment(desc: &str) -> Option<rust::Tokens> {
let lines = desc.trim().split("\n");
let formatted_lines = lines
.into_iter()
.map(write_comment_line)
.collect::<Vec<_>>();
if formatted_lines.len() > 0 {
Some(quote! {
$(for line in formatted_lines join($['\r']) => $line)
})
} else {
None
}

View File

@@ -10,7 +10,7 @@ fn render_enum_values(values: &FullType) -> Option<rust::Tokens> {
.map(|values| {
values
.into_iter()
.map(|val| quote! { $(val.name.as_ref()) })
.map(|val| quote! { $(val.name.as_ref()), })
})
.flatten()
.collect::<Vec<_>>();
@@ -25,7 +25,10 @@ fn render_enum_values(values: &FullType) -> Option<rust::Tokens> {
}
pub fn render_enum(t: &FullType) -> eyre::Result<rust::Tokens> {
let serialize = rust::import("serde", "Serialize");
Ok(quote! {
#[derive($serialize, Clone, PartialEq, Debug)]
pub enum $(t.name.as_ref()) {
$(render_enum_values(t))
}

View File

@@ -9,7 +9,7 @@ pub fn render_input(funcs: &CommonFunctions, t: &FullType) -> eyre::Result<rust:
let deserialize = rust::import("serde", "Deserialize");
let serialize = rust::import("serde", "Serialize");
Ok(quote! {
#[derive($serialize, $deserialize)]
#[derive($serialize, $deserialize, Debug, PartialEq, Clone)]
pub struct $(format_name(t.name.as_ref().unwrap())) {
$(render_input_fields(funcs, t.input_fields.as_ref().unwrap_or(&Vec::new()) ))
}
@@ -33,6 +33,6 @@ pub fn render_input_fields(
pub fn render_input_field(funcs: &CommonFunctions, field: &FullTypeInputFields) -> rust::Tokens {
quote! {
pub $(format_struct_name(&field.input_value.name)): $(funcs.format_input_type(&field.input_value.type_)),
pub $(format_struct_name(&field.input_value.name)): $(funcs.format_output_type(&field.input_value.type_)),
}
}

View File

@@ -1,16 +1,18 @@
use dagger_core::introspection::{FullType, FullTypeFields, FullTypeFieldsArgs};
use genco::prelude::rust;
use genco::quote;
use itertools::Itertools;
use crate::functions::{type_ref_is_optional, CommonFunctions};
use crate::functions::CommonFunctions;
use crate::rust::functions::{
field_options_struct_name, format_function, format_name, format_struct_name,
field_options_struct_name, format_function, format_name, format_optional_args,
format_struct_comment, format_struct_name,
};
use crate::utility::OptionExt;
pub fn render_object(funcs: &CommonFunctions, t: &FullType) -> eyre::Result<rust::Tokens> {
let selection = rust::import("crate::querybuilder", "Selection");
let child = rust::import("std::process", "Child");
let child = rust::import("tokio::process", "Child");
let conn = rust::import("dagger_core::connect_params", "ConnectParams");
let arc = rust::import("std::sync", "Arc");
@@ -50,20 +52,17 @@ fn render_optional_args(
fn render_optional_arg(funcs: &CommonFunctions, field: &FullTypeFields) -> Option<rust::Tokens> {
let output_type = field_options_struct_name(field);
let fields = field
.args
.pipe(|t| t.into_iter().flatten().collect::<Vec<_>>())
.map(|t| {
t.into_iter()
.filter(|t| type_ref_is_optional(&t.input_value.type_))
.collect::<Vec<_>>()
})
.pipe(|t| render_optional_field_args(funcs, t))
.flatten();
let fields = format_optional_args(funcs, field);
if let Some(fields) = fields {
let builder = rust::import("derive_builder", "Builder");
let _phantom_data = rust::import("std::marker", "PhantomData");
if let Some((fields, contains_lifetime)) = fields {
Some(quote! {
pub struct $output_type {
#[derive($builder, Debug, PartialEq)]
pub struct $output_type$(if contains_lifetime => <'a>) {
//#[builder(default, setter(skip))]
//pub marker: $(phantom_data)<&'a ()>,
$fields
}
})
@@ -72,22 +71,32 @@ fn render_optional_arg(funcs: &CommonFunctions, field: &FullTypeFields) -> Optio
}
}
fn render_optional_field_args(
pub fn render_optional_field_args(
funcs: &CommonFunctions,
args: &Vec<&FullTypeFieldsArgs>,
) -> Option<rust::Tokens> {
) -> Option<(rust::Tokens, bool)> {
if args.len() == 0 {
return None;
}
let mut contains_lifetime = false;
let rendered_args = args.into_iter().map(|a| &a.input_value).map(|a| {
let type_ = funcs.format_immutable_input_type(&a.type_);
if type_.contains("str") {
contains_lifetime = true;
}
quote! {
pub $(format_struct_name(&a.name)): Option<$(funcs.format_output_type(&a.type_))>,
$(a.description.pipe(|d| format_struct_comment(d)))
#[builder(setter(into, strip_option))]
pub $(format_struct_name(&a.name)): Option<$(type_)>,
}
});
Some(quote! {
$(for arg in rendered_args join ($['\r']) => $arg)
})
Some((
quote! {
$(for arg in rendered_args join ($['\r']) => $arg)
},
contains_lifetime,
))
}
fn render_functions(funcs: &CommonFunctions, fields: &Vec<FullTypeFields>) -> Option<rust::Tokens> {

View File

@@ -10,7 +10,7 @@ pub fn render_scalar(t: &FullType) -> eyre::Result<rust::Tokens> {
let serialize = rust::import("serde", "Serialize");
Ok(quote! {
#[derive($serialize, $deserialize)]
#[derive($serialize, $deserialize, PartialEq, Debug, Clone)]
pub struct $(t.name.pipe(|n|format_name(n)))(String);
})
}

View File

@@ -0,0 +1,151 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v0.2.5 (2023-02-20)
### Bug Fixes
- <csr-id-a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de/> race condition in process
### Commit Statistics
<csr-read-only-do-not-edit/>
- 1 commit contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- race condition in process ([`a13a2a9`](https://github.com/kjuulh/dagger-rs/commit/a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de))
</details>
## v0.2.4 (2023-02-20)
### Bug Fixes
- <csr-id-8385aa8a15ff7b45fecc3462c482b998118c14eb/> remove blocking
- <csr-id-921e61b5e248013cb5fbf4f1bad3eef5a2673145/> remove blocking
### Commit Statistics
<csr-read-only-do-not-edit/>
- 4 commits contributed to the release.
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`f869e57`](https://github.com/kjuulh/dagger-rs/commit/f869e574dd788cd60e5b1b5d502bec68e300694c))
- remove blocking ([`921e61b`](https://github.com/kjuulh/dagger-rs/commit/921e61b5e248013cb5fbf4f1bad3eef5a2673145))
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`17ec62a`](https://github.com/kjuulh/dagger-rs/commit/17ec62a5d58232ff57391523b9851fb7b07d02ab))
- remove blocking ([`8385aa8`](https://github.com/kjuulh/dagger-rs/commit/8385aa8a15ff7b45fecc3462c482b998118c14eb))
</details>
## v0.2.3 (2023-02-20)
### Bug Fixes
- <csr-id-75bc17e57db222492c6ffd2dfe80208d2bda75c9/> Fix async panic on blocking #19
Replaced internal threads with tokio spawn functions
### Commit Statistics
<csr-read-only-do-not-edit/>
- 2 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.3, dagger-sdk v0.2.9, dagger-rs v0.2.10 ([`82de43a`](https://github.com/kjuulh/dagger-rs/commit/82de43aa91d6a5e09a247d1959137fdc36a40d35))
- Fix async panic on blocking #19 ([`75bc17e`](https://github.com/kjuulh/dagger-rs/commit/75bc17e57db222492c6ffd2dfe80208d2bda75c9))
</details>
## v0.2.2 (2023-02-19)
### New Features
- <csr-id-6e5f4074329ab0462445b31d4153f8497c483438/> update to dagger v0.3.12
### Commit Statistics
<csr-read-only-do-not-edit/>
- 2 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.2, dagger-codegen v0.2.2, dagger-rs v0.2.8 ([`1638f15`](https://github.com/kjuulh/dagger-rs/commit/1638f15fba9d16512e8452f87b908d6dce417cd9))
- update to dagger v0.3.12 ([`6e5f407`](https://github.com/kjuulh/dagger-rs/commit/6e5f4074329ab0462445b31d4153f8497c483438))
</details>
## v0.2.1 (2023-02-18)
### Bug Fixes
- <csr-id-789b0e69c8c53d0e86d9cec89ab5345507aad514/> update all dependencies
### Commit Statistics
<csr-read-only-do-not-edit/>
- 16 commits contributed to the release over the course of 19 calendar days.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 2 unique issues were worked on: [#5](https://github.com/kjuulh/dagger-rs/issues/5), [#6](https://github.com/kjuulh/dagger-rs/issues/6)
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **[#5](https://github.com/kjuulh/dagger-rs/issues/5)**
- update all dependencies ([`789b0e6`](https://github.com/kjuulh/dagger-rs/commit/789b0e69c8c53d0e86d9cec89ab5345507aad514))
* **[#6](https://github.com/kjuulh/dagger-rs/issues/6)**
- feature/add impl ([`4a4c03f`](https://github.com/kjuulh/dagger-rs/commit/4a4c03f3c2ee7f6268c65976715e70767b4ea78d))
* **Uncategorized**
- Release dagger-core v0.2.1, dagger-codegen v0.2.1, dagger-rs v0.2.1 ([`1332bc8`](https://github.com/kjuulh/dagger-rs/commit/1332bc842ce2ea0254c651419813b63b36ca590c))
- add changelogs ([`a064684`](https://github.com/kjuulh/dagger-rs/commit/a064684fcf80196188a57d9ff9067c0b5769fb09))
- Adjusting changelogs prior to release of dagger-core v0.2.1, dagger-codegen v0.2.1, dagger-rs v0.2.1 ([`f4a20fd`](https://github.com/kjuulh/dagger-rs/commit/f4a20fda79063b29829cc899793775ba8cb17214))
- with publish ([`989d5bc`](https://github.com/kjuulh/dagger-rs/commit/989d5bc26036d46a199d939b5cbbe72aff2f8fb1))
- with repo ([`e5383b5`](https://github.com/kjuulh/dagger-rs/commit/e5383b51f3b290a87b729929c377e93bda3873e0))
- with readme and license ([`1e26b38`](https://github.com/kjuulh/dagger-rs/commit/1e26b383d4f6dbcbe20f5f7c19c749e743f6e607))
- bump version ([`36b0ecd`](https://github.com/kjuulh/dagger-rs/commit/36b0ecdabf4c220cffb2d0660fb6480387e3249a))
- with println ([`d1726a0`](https://github.com/kjuulh/dagger-rs/commit/d1726a052a6dc4e57f364864446cab3cbda7e0bf))
- context and querier done ([`52a0db3`](https://github.com/kjuulh/dagger-rs/commit/52a0db3e311f9f88447882f1406701d4cd612b1c))
- tested full flow initially ([`7a008be`](https://github.com/kjuulh/dagger-rs/commit/7a008be59e5ca183809e5840cdfae1d87665aa20))
- move code to dagger-core ([`ec0d0b2`](https://github.com/kjuulh/dagger-rs/commit/ec0d0b22e646c97acb3ce93f3afb3ddb8590e68f))
- add fields ([`496a687`](https://github.com/kjuulh/dagger-rs/commit/496a687bc34f7c58cc86df60c183be741b0b8a9c))
- with objects ([`5fef514`](https://github.com/kjuulh/dagger-rs/commit/5fef5148010f384d0158361d64b8e17d357d4819))
- with enum ([`2a1f7c3`](https://github.com/kjuulh/dagger-rs/commit/2a1f7c3f2666f1f4caebf7c22707709741c2cfad))
</details>

View File

@@ -1,6 +1,6 @@
[package]
name = "dagger-core"
version = "0.2.0"
version = "0.2.5"
edition = "2021"
readme = "README.md"
license-file = "LICENSE.MIT"
@@ -16,16 +16,14 @@ eyre = "0.6.8"
flate2 = { version = "1.0.25", features = ["zlib"] }
genco = "0.17.3"
graphql-introspection-query = "0.2.0"
graphql_client = { version = "0.12.0", features = [
"reqwest",
"reqwest-blocking",
] }
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", "blocking", "deflate"] }
reqwest = { version = "0.11.14", features = ["stream", "deflate"] }
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.93"
sha2 = "0.10.6"
tar = "0.4.38"
tempfile = "3.3.0"
tokio = { version = "1.25.0", features = ["full"] }

View File

@@ -3,9 +3,11 @@ use std::{
io::{BufRead, BufReader},
path::PathBuf,
process::{Child, Stdio},
sync::{mpsc::sync_channel, Arc},
sync::Arc,
};
use tokio::io::AsyncBufReadExt;
use crate::{config::Config, connect_params::ConnectParams};
#[derive(Clone, Debug)]
@@ -20,12 +22,12 @@ impl CliSession {
}
}
pub fn connect(
pub async fn connect(
&self,
config: &Config,
cli_path: &PathBuf,
) -> eyre::Result<(ConnectParams, Child)> {
self.inner.connect(config, cli_path)
) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
self.inner.connect(config, cli_path).await
}
}
@@ -33,17 +35,17 @@ impl CliSession {
struct InnerCliSession {}
impl InnerCliSession {
pub fn connect(
pub async fn connect(
&self,
config: &Config,
cli_path: &PathBuf,
) -> eyre::Result<(ConnectParams, Child)> {
) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
let proc = self.start(config, cli_path)?;
let params = self.get_conn(proc)?;
let params = self.get_conn(proc).await?;
Ok(params)
}
fn start(&self, config: &Config, cli_path: &PathBuf) -> eyre::Result<std::process::Child> {
fn start(&self, config: &Config, cli_path: &PathBuf) -> eyre::Result<tokio::process::Child> {
let mut args: Vec<String> = vec!["session".into()];
if let Some(workspace) = &config.workdir_path {
let abs_path = canonicalize(workspace)?;
@@ -54,7 +56,7 @@ impl InnerCliSession {
args.extend(["--project".into(), abs_path.to_string_lossy().to_string()])
}
let proc = std::process::Command::new(
let proc = tokio::process::Command::new(
cli_path
.to_str()
.ok_or(eyre::anyhow!("could not get string from path"))?,
@@ -70,10 +72,10 @@ impl InnerCliSession {
return Ok(proc);
}
fn get_conn(
async fn get_conn(
&self,
mut proc: std::process::Child,
) -> eyre::Result<(ConnectParams, std::process::Child)> {
mut proc: tokio::process::Child,
) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
let stdout = proc
.stdout
.take()
@@ -84,32 +86,32 @@ impl InnerCliSession {
.take()
.ok_or(eyre::anyhow!("could not acquire stderr from child process"))?;
let (sender, receiver) = sync_channel(1);
let (sender, mut receiver) = tokio::sync::mpsc::channel(1);
std::thread::spawn(move || {
let stdout_bufr = BufReader::new(stdout);
for line in stdout_bufr.lines() {
tokio::spawn(async move {
let stdout_bufr = tokio::io::BufReader::new(stdout);
for line in stdout_bufr.lines().next_line().await {
let out = line.as_ref().unwrap();
if let Ok(conn) = serde_json::from_str::<ConnectParams>(&out) {
sender.send(conn).unwrap();
sender.send(conn).await.unwrap();
}
if let Ok(line) = line {
if let Some(line) = line {
println!("dagger: {}", line);
}
}
});
std::thread::spawn(|| {
let stderr_bufr = BufReader::new(stderr);
for line in stderr_bufr.lines() {
if let Ok(line) = line {
tokio::spawn(async move {
let stdout_bufr = tokio::io::BufReader::new(stderr);
for line in stdout_bufr.lines().next_line().await {
if let Some(line) = line {
println!("dagger: {}", line);
}
//panic!("could not start dagger session: {}", out)
}
});
let conn = receiver.recv()?;
let conn = receiver.recv().await.ok_or(eyre::anyhow!("could not receive ok signal from dagger-engine"))?;
Ok((conn, proc))
}

View File

@@ -119,7 +119,7 @@ impl Downloader {
Ok(path)
}
pub fn get_cli(&self) -> eyre::Result<PathBuf> {
pub async fn get_cli(&self) -> eyre::Result<PathBuf> {
let version = &self.version;
let mut cli_bin_path = self.cache_dir()?;
cli_bin_path.push(format!("{CLI_BIN_PREFIX}{version}"));
@@ -129,7 +129,7 @@ impl Downloader {
if !cli_bin_path.exists() {
cli_bin_path = self
.download(cli_bin_path)
.download(cli_bin_path).await
.context("failed to download CLI from archive")?;
}
@@ -145,11 +145,11 @@ impl Downloader {
Ok(cli_bin_path)
}
fn download(&self, path: PathBuf) -> eyre::Result<PathBuf> {
let expected_checksum = self.expected_checksum()?;
async fn download(&self, path: PathBuf) -> eyre::Result<PathBuf> {
let expected_checksum = self.expected_checksum().await?;
let mut bytes = vec![];
let actual_hash = self.extract_cli_archive(&mut bytes)?;
let actual_hash = self.extract_cli_archive(&mut bytes).await?;
if expected_checksum != actual_hash {
eyre::bail!("downloaded CLI binary checksum doesn't match checksum from checksums.txt")
@@ -165,15 +165,15 @@ impl Downloader {
Ok(path)
}
fn expected_checksum(&self) -> eyre::Result<String> {
async fn expected_checksum(&self) -> eyre::Result<String> {
let archive_url = &self.archive_url();
let archive_path = PathBuf::from(&archive_url);
let archive_name = archive_path
.file_name()
.ok_or(eyre::anyhow!("could not get file_name from archive_url"))?;
let resp = reqwest::blocking::get(self.checksum_url())?;
let resp = reqwest::get(self.checksum_url()).await?;
let resp = resp.error_for_status()?;
for line in resp.text()?.lines() {
for line in resp.text().await?.lines() {
let mut content = line.split_whitespace();
let checksum = content
.next()
@@ -190,17 +190,13 @@ impl Downloader {
eyre::bail!("could not find a matching version or binary in checksums.txt")
}
pub fn extract_cli_archive(&self, dest: &mut Vec<u8>) -> eyre::Result<String> {
pub async fn extract_cli_archive(&self, dest: &mut Vec<u8>) -> eyre::Result<String> {
let archive_url = self.archive_url();
let resp = reqwest::blocking::get(&archive_url)?;
let mut resp = resp.error_for_status()?;
let mut bytes = vec![];
let lines = resp.read_to_end(&mut bytes)?;
if lines == 0 {
eyre::bail!("nothing was downloaded")
}
let resp = reqwest::get(&archive_url).await?;
let resp = resp.error_for_status()?;
let bytes = resp.bytes().await?;
let mut hasher = sha2::Sha256::new();
hasher.update(bytes.as_slice());
hasher.update(&bytes);
let res = hasher.finalize();
println!("{}", hex::encode(&res));
@@ -209,7 +205,7 @@ impl Downloader {
// TODO: Nothing for now
todo!()
} else {
self.extract_from_tar(bytes.as_slice(), dest)?;
self.extract_from_tar(&bytes, dest)?;
}
Ok(hex::encode(res))
@@ -240,9 +236,9 @@ impl Downloader {
mod test {
use super::Downloader;
#[test]
fn download() {
let cli_path = Downloader::new("0.3.10".into()).unwrap().get_cli().unwrap();
#[tokio::test]
async fn download() {
let cli_path = Downloader::new("0.3.10".into()).unwrap().get_cli().await.unwrap();
assert_eq!(
Some("dagger-0.3.10"),

View File

@@ -11,17 +11,17 @@ impl Engine {
Self {}
}
fn from_cli(&self, cfg: &Config) -> eyre::Result<(ConnectParams, Child)> {
let cli = Downloader::new("0.3.10".into())?.get_cli()?;
async fn from_cli(&self, cfg: &Config) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
let cli = Downloader::new("0.3.12".into())?.get_cli().await?;
let cli_session = CliSession::new();
Ok(cli_session.connect(cfg, &cli)?)
Ok(cli_session.connect(cfg, &cli).await?)
}
pub fn start(&self, cfg: &Config) -> eyre::Result<(ConnectParams, Child)> {
pub async fn start(&self, cfg: &Config) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
// TODO: Add from existing session as well
self.from_cli(cfg)
self.from_cli(cfg).await
}
}
@@ -32,10 +32,10 @@ mod tests {
use super::Engine;
// TODO: these tests potentially have a race condition
#[test]
fn engine_can_start() {
#[tokio::test]
async fn engine_can_start() {
let engine = Engine::new();
let params = engine.start(&Config::new(None, None, None, None)).unwrap();
let params = engine.start(&Config::new(None, None, None, None)).await.unwrap();
assert_ne!(
params.0,

View File

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

View File

@@ -1,7 +1,7 @@
use graphql_client::GraphQLQuery;
use reqwest::{
blocking::{Client, RequestBuilder},
header::{HeaderMap, HeaderValue, ACCEPT, CONTENT_TYPE},
Client, RequestBuilder,
};
use crate::{config::Config, connect_params::ConnectParams, introspection::IntrospectionResponse};
@@ -37,14 +37,14 @@ impl Session {
Ok(req_builder)
}
pub fn schema(&self, req_builder: RequestBuilder) -> eyre::Result<IntrospectionResponse> {
pub async fn schema(&self, req_builder: RequestBuilder) -> eyre::Result<IntrospectionResponse> {
let request_body: graphql_client::QueryBody<()> = graphql_client::QueryBody {
variables: (),
query: introspection_query::QUERY,
operation_name: introspection_query::OPERATION_NAME,
};
let res = req_builder.json(&request_body).send()?;
let res = req_builder.json(&request_body).send().await?;
if res.status().is_success() {
// do nothing
@@ -52,7 +52,7 @@ impl Session {
return Err(eyre::anyhow!("server error!"));
} else {
let status = res.status();
let error_message = match res.text() {
let error_message = match res.text().await {
Ok(msg) => match serde_json::from_str::<serde_json::Value>(&msg) {
Ok(json) => {
format!("HTTP {}\n{}", status, serde_json::to_string_pretty(&json)?)
@@ -64,7 +64,7 @@ impl Session {
return Err(eyre::anyhow!(error_message));
}
let json: IntrospectionResponse = res.json()?;
let json: IntrospectionResponse = res.json().await?;
Ok(json)
}

View File

@@ -0,0 +1,470 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## v0.2.12 (2023-02-20)
### Bug Fixes
- <csr-id-a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de/> race condition in process
### Commit Statistics
<csr-read-only-do-not-edit/>
- 1 commit contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- race condition in process ([`a13a2a9`](https://github.com/kjuulh/dagger-rs/commit/a13a2a9ecbfdfac80ed8eb0cbb9e9db317da65de))
</details>
## v0.2.11 (2023-02-20)
<csr-id-803cfc4f8c4d72ab7d011be5523b3bfc6039de39/>
### Chore
- <csr-id-803cfc4f8c4d72ab7d011be5523b3bfc6039de39/> ran clippy
### Commit Statistics
<csr-read-only-do-not-edit/>
- 3 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`f869e57`](https://github.com/kjuulh/dagger-rs/commit/f869e574dd788cd60e5b1b5d502bec68e300694c))
- Release dagger-core v0.2.4, dagger-codegen v0.2.6, dagger-sdk v0.2.11 ([`17ec62a`](https://github.com/kjuulh/dagger-rs/commit/17ec62a5d58232ff57391523b9851fb7b07d02ab))
- ran clippy ([`803cfc4`](https://github.com/kjuulh/dagger-rs/commit/803cfc4f8c4d72ab7d011be5523b3bfc6039de39))
</details>
## v0.2.10 (2023-02-20)
Alignment release
### Bug Fixes
- <csr-id-b100285312df522218bfd4bc00bbf41b857a81bf/> changelog
### Commit Statistics
<csr-read-only-do-not-edit/>
- 8 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-sdk v0.2.10 ([`5cb9729`](https://github.com/kjuulh/dagger-rs/commit/5cb97296b61677fb37e4bdb8519d30a484f93621))
- changelog ([`b100285`](https://github.com/kjuulh/dagger-rs/commit/b100285312df522218bfd4bc00bbf41b857a81bf))
- Adjusting changelogs prior to release of dagger-sdk v0.2.10 ([`8ed0647`](https://github.com/kjuulh/dagger-rs/commit/8ed06476e56f3290a419d2a67e7f25da575c63ad))
- update changelog ([`09aa658`](https://github.com/kjuulh/dagger-rs/commit/09aa658b6fb3c1e9a2de668c4a69bbe5be13202f))
- Adjusting changelogs prior to release of dagger-sdk v0.2.10 ([`b436f27`](https://github.com/kjuulh/dagger-rs/commit/b436f27a535f085bb8a4e66c7c4b3df461e74c21))
- Adjusting changelogs prior to release of dagger-sdk v0.2.10, dagger-rs v0.2.10 ([`577a293`](https://github.com/kjuulh/dagger-rs/commit/577a293c6777b9305a4f5fc7c3abee4aff4d74b5))
- Adjusting changelogs prior to release of dagger-sdk v0.2.10, dagger-rs v0.2.10 ([`76bb1fc`](https://github.com/kjuulh/dagger-rs/commit/76bb1fcedd03bd2d3b1e0f841f10325e4a85e108))
- Release dagger-rs v0.2.10 ([`dc3487b`](https://github.com/kjuulh/dagger-rs/commit/dc3487b840beb9543699f72d4282147e4ebc72f2))
</details>
## v0.2.10
([`577a293`](https://github.com/kjuulh/dagger-rs/commit/577a293c6777b9305a4f5fc7c3abee4aff4d74b5))
- Adjusting changelogs prior to release of dagger-sdk v0.2.10, dagger-rs
## v0.2.10
([`76bb1fc`](https://github.com/kjuulh/dagger-rs/commit/76bb1fcedd03bd2d3b1e0f841f10325e4a85e108))
- Release dagger-rs v0.2.10
([`dc3487b`](https://github.com/kjuulh/dagger-rs/commit/dc3487b840beb9543699f72d4282147e4ebc72f2))
</details>
## v0.2.10
([`577a293`](https://github.com/kjuulh/dagger-rs/commit/577a293c6777b9305a4f5fc7c3abee4aff4d74b5))
- Adjusting changelogs prior to release of dagger-sdk v0.2.10, dagger-rs
## v0.2.10
([`76bb1fc`](https://github.com/kjuulh/dagger-rs/commit/76bb1fcedd03bd2d3b1e0f841f10325e4a85e108))
- Release dagger-rs v0.2.10
([`dc3487b`](https://github.com/kjuulh/dagger-rs/commit/dc3487b840beb9543699f72d4282147e4ebc72f2))
</details>
## v0.2.9 (2023-02-20)
### Bug Fixes
- <csr-id-75bc17e57db222492c6ffd2dfe80208d2bda75c9/> Fix async panic on blocking
#19 Replaced internal threads with tokio spawn functions
### Commit Statistics
<csr-read-only-do-not-edit/>
- 2 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-core v0.2.3, dagger-sdk v0.2.9, dagger-rs v0.2.10 ([`82de43a`](https://github.com/kjuulh/dagger-rs/commit/82de43aa91d6a5e09a247d1959137fdc36a40d35))
- Fix async panic on blocking #19 ([`75bc17e`](https://github.com/kjuulh/dagger-rs/commit/75bc17e57db222492c6ffd2dfe80208d2bda75c9))
</details>
## v0.2.8 (2023-02-19)
### New Features
- <csr-id-978ede68ae52f5b5150a2aa45b8d6e1fbbbee2f4/> add documentation strings
### Commit Statistics
<csr-read-only-do-not-edit/>
- 2 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-sdk v0.2.8, dagger-codegen v0.2.5 ([`0499024`](https://github.com/kjuulh/dagger-rs/commit/04990247ba8e9d0555847f582fef14849dbedebf))
- add documentation strings ([`978ede6`](https://github.com/kjuulh/dagger-rs/commit/978ede68ae52f5b5150a2aa45b8d6e1fbbbee2f4))
</details>
## v0.2.7 (2023-02-19)
### Documentation
- <csr-id-93f40b356c48f14e910968516bed9487912095c1/> change to await syntax
### New Features
- <csr-id-9be6f435d9ea39f31a8906e55dbd3e8b1e5ec598/> Use async runtime instead
of blocking. Default to using async runtime instead of blocking. I.e.
```rust
fn main() -> eyre::Result<()> {
// ...
client.container().from("rust").publish("somewhere")?;
// ...
}
// to
async fn main() -> eyre::Result<()> {
// ...
client.container().from("rust").publish("somewhere").await?;
// ...
}
```
### Commit Statistics
<csr-read-only-do-not-edit/>
- 3 commits contributed to the release.
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-sdk v0.2.7 ([`a1887af`](https://github.com/kjuulh/dagger-rs/commit/a1887afc8b51f61491ba7f13c5e7a5b7619623c4))
- change to await syntax ([`93f40b3`](https://github.com/kjuulh/dagger-rs/commit/93f40b356c48f14e910968516bed9487912095c1))
- Use async runtime instead of blocking. ([`9be6f43`](https://github.com/kjuulh/dagger-rs/commit/9be6f435d9ea39f31a8906e55dbd3e8b1e5ec598))
</details>
## v0.2.6 (2023-02-19)
### Documentation
- <csr-id-04e70ce964b343e28b3dbd0c46d10ccda958ab8c/> fix readme
### Commit Statistics
<csr-read-only-do-not-edit/>
- 2 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-sdk v0.2.6 ([`c312bc5`](https://github.com/kjuulh/dagger-rs/commit/c312bc57ad3e5380b6a2a927f3bb758aa5344efd))
- fix readme ([`04e70ce`](https://github.com/kjuulh/dagger-rs/commit/04e70ce964b343e28b3dbd0c46d10ccda958ab8c))
</details>
## v0.2.5 (2023-02-19)
### New Features
- <csr-id-f29ff836cfd72d5e051ca6a71a230ba1e9933091/> without Some in _opts
functions Option has been removed as a wrapper around opts. This makes it much
more convenient to use
```rust
client.container_opts(Some(ContainerOpts{}))
// ->
client.container_opts(ContainerOpts{})
```
The same options are still available, either an empty object can be passed, or
a non _opts function can be used
- <csr-id-9762da895a164e30c5dc60e89a83e934ceae47ab/> with _opts methods Now all
opt values enter into a _opts function instead of the original. This avoids a
lot of verbosity for both None in the case opts are unwanted, and Some() if
they actually are.
They are used like so:
```rust
client.container().from("...");
client.container_opts(Some(ContainerOpts{ ... }))
```
Some from opts will be removed in a future commit/pr
- <csr-id-94336d06378f035464e233b921dc3858070f582d/> move to &str instead of
String and introduce builder. This will make the api much easier to use, as we
can now rely on "" instead of "".into() for normal string values.
Introduced builder as well, which makes it much easier to use *Opts, as it can
handle the building of that, and get the benefits from String -> &str, as that
is currently not allowed for optional values
### Bug Fixes
- <csr-id-c627595fd2695e236924175d137c42f1480ccd6b/> cargo clippy
- <csr-id-02006d40fc2c0383e0412c15c36db9af7eda991f/> without phantom data
- <csr-id-6e2292cf11942fbd26a52fe4e0fc8471e6eb70a3/> dependencies
### Commit Statistics
<csr-read-only-do-not-edit/>
- 7 commits contributed to the release.
- 6 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-sdk v0.2.5, dagger-codegen v0.2.4 ([`f727318`](https://github.com/kjuulh/dagger-rs/commit/f72731807d8358fdb3d80432136b7a08bb7b1773))
- cargo clippy ([`c627595`](https://github.com/kjuulh/dagger-rs/commit/c627595fd2695e236924175d137c42f1480ccd6b))
- without Some in _opts functions ([`f29ff83`](https://github.com/kjuulh/dagger-rs/commit/f29ff836cfd72d5e051ca6a71a230ba1e9933091))
- with _opts methods ([`9762da8`](https://github.com/kjuulh/dagger-rs/commit/9762da895a164e30c5dc60e89a83e934ceae47ab))
- without phantom data ([`02006d4`](https://github.com/kjuulh/dagger-rs/commit/02006d40fc2c0383e0412c15c36db9af7eda991f))
- move to &str instead of String and introduce builder. ([`94336d0`](https://github.com/kjuulh/dagger-rs/commit/94336d06378f035464e233b921dc3858070f582d))
- dependencies ([`6e2292c`](https://github.com/kjuulh/dagger-rs/commit/6e2292cf11942fbd26a52fe4e0fc8471e6eb70a3))
</details>
## v0.2.4 (2023-02-19)
### Bug Fixes
- <csr-id-7d04ab1240e497e7804fed23a378d28c78f50a0a/> readme dagger-rs ->
dagger-sdk
### Commit Statistics
<csr-read-only-do-not-edit/>
- 2 commits contributed to the release.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-sdk v0.2.4 ([`cc81124`](https://github.com/kjuulh/dagger-rs/commit/cc81124f899f44f80c1ee7d1e23a7e02d8cc4b7c))
- readme dagger-rs -> dagger-sdk ([`7d04ab1`](https://github.com/kjuulh/dagger-rs/commit/7d04ab1240e497e7804fed23a378d28c78f50a0a))
</details>
## v0.2.3 (2023-02-19)
### New Features
- <csr-id-19ed6c267f779b72430422c463ceed553f6fc618/> re-export through lib.rs
this means that you can now use dagger_sdk::connect() instead of
dagger_sdk::client::connect();
- <csr-id-de063eae858eb3335d2558a57ee6a88689635200/> with return result instead
of unwrap
- <csr-id-5d667369900a47d3a6015cd3814c240bc5c54436/> remove unnecessary option
returns
### Commit Statistics
<csr-read-only-do-not-edit/>
- 4 commits contributed to the release.
- 3 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-sdk v0.2.3, dagger-codegen v0.2.3, dagger-rs v0.2.9 ([`9235030`](https://github.com/kjuulh/dagger-rs/commit/92350306b3f0da40b4fc6dcaffcd90b891e83f70))
- re-export through lib.rs ([`19ed6c2`](https://github.com/kjuulh/dagger-rs/commit/19ed6c267f779b72430422c463ceed553f6fc618))
- with return result instead of unwrap ([`de063ea`](https://github.com/kjuulh/dagger-rs/commit/de063eae858eb3335d2558a57ee6a88689635200))
- remove unnecessary option returns ([`5d66736`](https://github.com/kjuulh/dagger-rs/commit/5d667369900a47d3a6015cd3814c240bc5c54436))
</details>
## v0.2.2 (2023-02-19)
### New Features
- <csr-id-6e5f4074329ab0462445b31d4153f8497c483438/> update to dagger v0.3.12
### Bug Fixes
- <csr-id-10bc6f3846b65cc82c2fb343d8cfe921784bef1b/> fixed fmt errors
### Commit Statistics
<csr-read-only-do-not-edit/>
- 4 commits contributed to the release.
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
- 0 issues like '(#ID)' were seen in commit messages
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **Uncategorized**
- Release dagger-sdk v0.2.2 ([`e921ba1`](https://github.com/kjuulh/dagger-rs/commit/e921ba13638987ccf5beaa48c4be9be5fd879bd0))
- Release dagger-core v0.2.2, dagger-codegen v0.2.2, dagger-rs v0.2.8 ([`1638f15`](https://github.com/kjuulh/dagger-rs/commit/1638f15fba9d16512e8452f87b908d6dce417cd9))
- fixed fmt errors ([`10bc6f3`](https://github.com/kjuulh/dagger-rs/commit/10bc6f3846b65cc82c2fb343d8cfe921784bef1b))
- update to dagger v0.3.12 ([`6e5f407`](https://github.com/kjuulh/dagger-rs/commit/6e5f4074329ab0462445b31d4153f8497c483438))
</details>
## v0.2.1 (2023-02-18)
### Bug Fixes
- <csr-id-789b0e69c8c53d0e86d9cec89ab5345507aad514/> update all dependencies
### Commit Statistics
<csr-read-only-do-not-edit/>
- 40 commits contributed to the release over the course of 20 calendar days.
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
- 2 unique issues were worked on: [#5](https://github.com/kjuulh/dagger-rs/issues/5), [#6](https://github.com/kjuulh/dagger-rs/issues/6)
### Commit Details
<csr-read-only-do-not-edit/>
<details><summary>view details</summary>
* **[#5](https://github.com/kjuulh/dagger-rs/issues/5)**
- update all dependencies ([`789b0e6`](https://github.com/kjuulh/dagger-rs/commit/789b0e69c8c53d0e86d9cec89ab5345507aad514))
* **[#6](https://github.com/kjuulh/dagger-rs/issues/6)**
- feature/add impl ([`4a4c03f`](https://github.com/kjuulh/dagger-rs/commit/4a4c03f3c2ee7f6268c65976715e70767b4ea78d))
* **Uncategorized**
- Release dagger-sdk v0.2.1 ([`aa0c397`](https://github.com/kjuulh/dagger-rs/commit/aa0c397b15566840eb59ca6186c083f631cc460b))
- add dagger-sdk changelog ([`11a5247`](https://github.com/kjuulh/dagger-rs/commit/11a5247933736bc6a4c5300c29599c88597fefb7))
- Release dagger-rs v0.2.7, dagger-sdk v0.2.1 ([`20c7118`](https://github.com/kjuulh/dagger-rs/commit/20c71189f6d5d978286ee16f8e958c6045756d80))
- Adjusting changelogs prior to release of dagger-core v0.2.1, dagger-codegen v0.2.1, dagger-rs v0.2.1 ([`f4a20fd`](https://github.com/kjuulh/dagger-rs/commit/f4a20fda79063b29829cc899793775ba8cb17214))
- with actual versions ([`7153c24`](https://github.com/kjuulh/dagger-rs/commit/7153c24f0105a05f170efd10ef2535d83ce0c87e))
- with publish ([`989d5bc`](https://github.com/kjuulh/dagger-rs/commit/989d5bc26036d46a199d939b5cbbe72aff2f8fb1))
- with repo ([`e5383b5`](https://github.com/kjuulh/dagger-rs/commit/e5383b51f3b290a87b729929c377e93bda3873e0))
- with wildcard version ([`533b9df`](https://github.com/kjuulh/dagger-rs/commit/533b9dfef0165c514127a8437d08daf52adf5739))
- cargo version 0.2.0 ([`bec62de`](https://github.com/kjuulh/dagger-rs/commit/bec62de62ff5638428174e232a36eee3ddd0f5ef))
- bump version ([`36b0ecd`](https://github.com/kjuulh/dagger-rs/commit/36b0ecdabf4c220cffb2d0660fb6480387e3249a))
- document usage ([`578c2a6`](https://github.com/kjuulh/dagger-rs/commit/578c2a68830eb40da888823a8770af4a764ed4c7))
- fix all clippy ([`6be8482`](https://github.com/kjuulh/dagger-rs/commit/6be8482b461e098384bbf1371ed7d67b259197fa))
- add with dockerfile ([`0cbd179`](https://github.com/kjuulh/dagger-rs/commit/0cbd1790b0b4030c68f0a0dd619325da26f14f60))
- with caching ([`728840c`](https://github.com/kjuulh/dagger-rs/commit/728840ca8e48b8bec66da4e5fa677bfa60d1d147))
- add more quickstart ([`59e2572`](https://github.com/kjuulh/dagger-rs/commit/59e2572173872c8091a0613a387a01e0cccc51bf))
- build the application ([`d894def`](https://github.com/kjuulh/dagger-rs/commit/d894def70c85ff2fc567bf614e3be6f4134965e2))
- add test-the-application ([`cb9a4dd`](https://github.com/kjuulh/dagger-rs/commit/cb9a4dd84fc13ef03ca3ad539646e95c3c047676))
- with println ([`d1726a0`](https://github.com/kjuulh/dagger-rs/commit/d1726a052a6dc4e57f364864446cab3cbda7e0bf))
- unpack response ([`3b5b59b`](https://github.com/kjuulh/dagger-rs/commit/3b5b59ba1c20cc68218dc5c0af18ff7a78f6953d))
- tested full flow initially ([`7a008be`](https://github.com/kjuulh/dagger-rs/commit/7a008be59e5ca183809e5840cdfae1d87665aa20))
- move code to dagger-core ([`ec0d0b2`](https://github.com/kjuulh/dagger-rs/commit/ec0d0b22e646c97acb3ce93f3afb3ddb8590e68f))
- with selection impl default ([`9f0021b`](https://github.com/kjuulh/dagger-rs/commit/9f0021b7086046c80b3f455f205149e03eb72da2))
- fix warnings ([`2b49f9c`](https://github.com/kjuulh/dagger-rs/commit/2b49f9c19098d96df2bb735253710774b0831c94))
- fix test ([`03366b7`](https://github.com/kjuulh/dagger-rs/commit/03366b7c5b3cce5ec42b5c7655843170236c56a1))
- test marshaller ([`c5dfceb`](https://github.com/kjuulh/dagger-rs/commit/c5dfcebaad9c255b10ba8c6e4d4dba00821c8941))
- test marshaller ([`c4ec6f0`](https://github.com/kjuulh/dagger-rs/commit/c4ec6f0c976ce0af2e05e818731b5e2bed7f0522))
- implement sort by name and type ([`d9b51c1`](https://github.com/kjuulh/dagger-rs/commit/d9b51c1ac90c00fb3af24332b6140e1201bc9be7))
- fix optional types for real ([`26069a8`](https://github.com/kjuulh/dagger-rs/commit/26069a82a69ec7265216c8ddaceb37228dd0fb81))
- fix description ([`f4581ba`](https://github.com/kjuulh/dagger-rs/commit/f4581ba4cd1693a906eaf6c58054398ceae3bfac))
- with proper optional types ([`f4a812a`](https://github.com/kjuulh/dagger-rs/commit/f4a812a7d24e9e09cb4e3cbde56ee0b3ac774b62))
- set proper option type ([`8549cfc`](https://github.com/kjuulh/dagger-rs/commit/8549cfc3a7d9f831febaeadc22db36604e465ea8))
- add fields ([`496a687`](https://github.com/kjuulh/dagger-rs/commit/496a687bc34f7c58cc86df60c183be741b0b8a9c))
- add input_fields ([`d2cddff`](https://github.com/kjuulh/dagger-rs/commit/d2cddff365c636feceb3f20a73df812fcab11a19))
- with objects ([`5fef514`](https://github.com/kjuulh/dagger-rs/commit/5fef5148010f384d0158361d64b8e17d357d4819))
- with enum ([`2a1f7c3`](https://github.com/kjuulh/dagger-rs/commit/2a1f7c3f2666f1f4caebf7c22707709741c2cfad))
- with codegen output ([`0bf6b0e`](https://github.com/kjuulh/dagger-rs/commit/0bf6b0e91ecc31c1f6b51338234137eb185810a0))
- split out codegen parts ([`3263f1d`](https://github.com/kjuulh/dagger-rs/commit/3263f1d589aee78065401c666533cb0cbadd06ce))
- add dagger-sdk ([`9dccb83`](https://github.com/kjuulh/dagger-rs/commit/9dccb83d94a720dd58deffe9f3e5aaea784336f3))
</details>

View File

@@ -1,6 +1,6 @@
[package]
name = "dagger-sdk"
version = "0.2.0"
version = "0.2.12"
edition = "2021"
readme = "README.md"
license-file = "LICENSE.MIT"
@@ -11,17 +11,18 @@ publish = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dagger-core = { path = "../dagger-core", version = "^0.2.5" }
base64 = "0.21.0"
dagger-core = { path = "../dagger-core", version = "0.2.0" }
eyre = "0.6.8"
futures = "0.3.26"
genco = "0.17.3"
gql_client = "1.0.7"
pretty_assertions = "1.3.0"
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.93"
tokio = { version = "1.25.0", features = ["full"] }
derive_builder = "0.12.0"
[dev-dependencies]
pretty_assertions = "1.3.0"
rand = "0.8.5"
genco = "0.17.3"

View File

@@ -1,4 +1,4 @@
# dagger-rs
# dagger-sdk
A dagger sdk written in rust for rust.
@@ -19,20 +19,21 @@ The examples match the folder name in each directory in examples
Simply install like:
```bash
cargo install dagger-sdk
cargo add dagger-sdk
```
### Usage
```rust
fn main() -> eyre::Result<()> {
let client = dagger_sdk::client::connect()?;
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect()?;
let version = client
.container(None)
.from("golang:1.19".into())
.with_exec(vec!["go".into(), "version".into()], None)
.stdout();
.container()
.from("golang:1.19")
.with_exec(vec!["go", "version"])
.stdout().await?;
println!("Hello from Dagger and {}", version.trim());
@@ -45,3 +46,9 @@ And run it like a normal application:
```bash
cargo run
```
### Disclaimer
You are free to use something else than `tokio`, I haven't tested it with
anything else, but it should work with any other runtime. We don't rely on it
specifically. That might change in the future though.

View File

@@ -1,42 +1,35 @@
use dagger_sdk::gen::HostDirectoryOpts;
use dagger_sdk::HostDirectoryOpts;
fn main() -> eyre::Result<()> {
let client = dagger_sdk::client::connect()?;
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect().await?;
let host_source_dir = client.host().directory(
"examples/build-the-application/app".into(),
Some(HostDirectoryOpts {
let host_source_dir = client.host().directory_opts(
"examples/build-the-application/app",
HostDirectoryOpts {
exclude: Some(vec!["node_modules".into(), "ci/".into()]),
include: None,
}),
},
);
let source = client
.container(None)
.from("node:16".into())
.with_mounted_directory("/src".into(), host_source_dir.id());
.container()
.from("node:16")
.with_mounted_directory("/src", host_source_dir.id().await?);
let runner = source
.with_workdir("/src".into())
.with_exec(vec!["npm".into(), "install".into()], None);
.with_workdir("/src")
.with_exec(vec!["npm", "install"]);
let test = runner.with_exec(
vec![
"npm".into(),
"test".into(),
"--".into(),
"--watchAll=false".into(),
],
None,
);
let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"]);
let build_dir = test
.with_exec(vec!["npm".into(), "run".into(), "build".into()], None)
.directory("./build".into());
.with_exec(vec!["npm", "run", "build"])
.directory("./build");
let _ = build_dir.export("./build".into());
let _ = build_dir.export("./build");
let entries = build_dir.entries(None);
let entries = build_dir.entries().await;
println!("build dir contents: \n {:?}", entries);

View File

@@ -1,53 +1,41 @@
use dagger_sdk::gen::HostDirectoryOpts;
use rand::Rng;
fn main() -> eyre::Result<()> {
let client = dagger_sdk::client::connect()?;
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect().await?;
let host_source_dir = client.host().directory(
"./examples/caching/app".into(),
Some(HostDirectoryOpts {
exclude: Some(vec!["node_modules".into(), "ci/".into()]),
include: None,
}),
let host_source_dir = client.host().directory_opts(
"./examples/caching/app",
dagger_sdk::HostDirectoryOptsBuilder::default()
.exclude(vec!["node_modules", "ci/"])
.build()?,
);
let node_cache = client.cache_volume("node".into()).id();
let node_cache = client.cache_volume("node").id().await?;
let source = client
.container(None)
.from("node:16".into())
.with_mounted_directory("/src".into(), host_source_dir.id())
.with_mounted_cache("/src/node_modules".into(), node_cache, None);
.container()
.from("node:16")
.with_mounted_directory("/src", host_source_dir.id().await?)
.with_mounted_cache("/src/node_modules", node_cache);
let runner = source
.with_workdir("/src".into())
.with_exec(vec!["npm".into(), "install".into()], None);
.with_workdir("/src")
.with_exec(vec!["npm", "install"]);
let test = runner.with_exec(
vec![
"npm".into(),
"test".into(),
"--".into(),
"--watchAll=false".into(),
],
None,
);
let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"]);
let build_dir = test
.with_exec(vec!["npm".into(), "run".into(), "build".into()], None)
.directory("./build".into());
.with_exec(vec!["npm", "run", "build"])
.directory("./build");
let mut rng = rand::thread_rng();
let ref_ = client
.container(None)
.from("nginx".into())
.with_directory("/usr/share/nginx/html".into(), build_dir.id(), None)
.publish(
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
None,
);
.container()
.from("nginx")
.with_directory("/usr/share/nginx/html", build_dir.id().await?)
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>())).await?;
println!("published image to: {}", ref_);

View File

@@ -1,22 +1,19 @@
use rand::Rng;
fn main() -> eyre::Result<()> {
#[tokio::main]
async fn main() -> eyre::Result<()> {
let mut rng = rand::thread_rng();
let client = dagger_sdk::client::connect()?;
let client = dagger_sdk::connect().await?;
let context_dir = client
.host()
.directory("./examples/existing-dockerfile/app".into(), None);
.directory("./examples/existing-dockerfile/app");
let ref_ = client
.container(None)
.build(context_dir.id(), None)
.publish(
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
None,
);
.container()
.build(context_dir.id().await?)
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>())).await?;
println!("published image to: {}", ref_);

View File

@@ -1,11 +1,12 @@
fn main() -> eyre::Result<()> {
let client = dagger_sdk::client::connect()?;
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect().await?;
let version = client
.container(None)
.from("golang:1.19".into())
.with_exec(vec!["go".into(), "version".into()], None)
.stdout();
.container()
.from("golang:1.19")
.with_exec(vec!["go", "version"])
.stdout().await?;
println!("Hello from Dagger and {}", version.trim());

View File

@@ -1,50 +1,41 @@
use dagger_sdk::gen::HostDirectoryOpts;
use dagger_sdk::HostDirectoryOpts;
use rand::Rng;
fn main() -> eyre::Result<()> {
let client = dagger_sdk::client::connect()?;
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect().await?;
let host_source_dir = client.host().directory(
"examples/publish-the-application/app".into(),
Some(HostDirectoryOpts {
exclude: Some(vec!["node_modules".into(), "ci/".into()]),
let host_source_dir = client.host().directory_opts(
"examples/publish-the-application/app",
HostDirectoryOpts {
exclude: Some(vec!["node_modules", "ci/"]),
include: None,
}),
},
);
let source = client
.container(None)
.from("node:16".into())
.with_mounted_directory("/src".into(), host_source_dir.id());
.container()
.from("node:16")
.with_mounted_directory("/src", host_source_dir.id().await?);
let runner = source
.with_workdir("/src".into())
.with_exec(vec!["npm".into(), "install".into()], None);
.with_workdir("/src")
.with_exec(vec!["npm", "install"]);
let test = runner.with_exec(
vec![
"npm".into(),
"test".into(),
"--".into(),
"--watchAll=false".into(),
],
None,
);
let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"]);
let build_dir = test
.with_exec(vec!["npm".into(), "run".into(), "build".into()], None)
.directory("./build".into());
.with_exec(vec!["npm", "run", "build"])
.directory("./build");
let mut rng = rand::thread_rng();
let ref_ = client
.container(None)
.from("nginx".into())
.with_directory("/usr/share/nginx/html".into(), build_dir.id(), None)
.publish(
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
None,
);
.container()
.from("nginx")
.with_directory("/usr/share/nginx/html", build_dir.id().await?)
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()))
.await?;
println!("published image to: {}", ref_);

View File

@@ -1,56 +1,45 @@
use dagger_sdk::gen::HostDirectoryOpts;
use dagger_sdk::HostDirectoryOpts;
use rand::Rng;
fn main() -> eyre::Result<()> {
let client = dagger_sdk::client::connect()?;
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect().await?;
let output = "examples/publish-the-application/app/build";
let host_source_dir = client.host().directory(
"examples/publish-the-application/app".into(),
Some(HostDirectoryOpts {
exclude: Some(vec!["node_modules".into(), "ci/".into()]),
let host_source_dir = client.host().directory_opts(
"examples/publish-the-application/app",
HostDirectoryOpts {
exclude: Some(vec!["node_modules", "ci/"]),
include: None,
}),
},
);
let source = client
.container(None)
.from("node:16".into())
.with_mounted_directory("/src".into(), host_source_dir.id());
.container()
.from("node:16")
.with_mounted_directory("/src", host_source_dir.id().await?);
let runner = source
.with_workdir("/src".into())
.with_exec(vec!["npm".into(), "install".into()], None);
.with_workdir("/src")
.with_exec(vec!["npm", "install"]);
let test = runner.with_exec(
vec![
"npm".into(),
"test".into(),
"--".into(),
"--watchAll=false".into(),
],
None,
);
let test = runner.with_exec(vec!["npm", "test", "--", "--watchAll=false"]);
let _ = test
.with_exec(vec!["npm".into(), "run".into(), "build".into()], None)
.directory("./build".into())
.export(output.into());
.with_exec(vec!["npm", "run", "build"])
.directory("./build")
.export(output);
let mut rng = rand::thread_rng();
let ref_ = client
.container(None)
.from("nginx".into())
.container()
.from("nginx")
.with_directory(
"/usr/share/nginx/html".into(),
client.host().directory(output.into(), None).id(),
None,
"/usr/share/nginx/html",
client.host().directory(output).id().await?,
)
.publish(
format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>()),
None,
);
.publish(format!("ttl.sh/hello-dagger-rs-{}:1h", rng.gen::<u64>())).await?;
println!("published image to: {}", ref_);

View File

@@ -1,36 +1,29 @@
use dagger_sdk::gen::HostDirectoryOpts;
use dagger_sdk::HostDirectoryOpts;
fn main() -> eyre::Result<()> {
let client = dagger_sdk::client::connect()?;
#[tokio::main]
async fn main() -> eyre::Result<()> {
let client = dagger_sdk::connect().await?;
let host_source_dir = client.host().directory(
"examples/test-the-application/app".into(),
Some(HostDirectoryOpts {
exclude: Some(vec!["node_modules".into(), "ci/".into()]),
let host_source_dir = client.host().directory_opts(
"examples/test-the-application/app",
HostDirectoryOpts {
exclude: Some(vec!["node_modules", "ci/"]),
include: None,
}),
},
);
let source = client
.container(None)
.from("node:16".into())
.with_mounted_directory("/src".into(), host_source_dir.id());
.container()
.from("node:16")
.with_mounted_directory("/src", host_source_dir.id().await?);
let runner = source
.with_workdir("/src".into())
.with_exec(vec!["npm".into(), "install".into()], None);
.with_workdir("/src")
.with_exec(vec!["npm", "install"]);
let out = runner
.with_exec(
vec![
"npm".into(),
"test".into(),
"--".into(),
"--watchAll=false".into(),
],
None,
)
.stderr();
.with_exec(vec!["npm", "test", "--", "--watchAll=false"])
.stderr().await?;
println!("{}", out);

View File

@@ -13,9 +13,9 @@ use crate::querybuilder::query;
pub type DaggerConn = Arc<Query>;
pub fn connect() -> eyre::Result<DaggerConn> {
pub async fn connect() -> eyre::Result<DaggerConn> {
let cfg = Config::default();
let (conn, proc) = DaggerEngine::new().start(&cfg)?;
let (conn, proc) = DaggerEngine::new().start(&cfg).await?;
Ok(Arc::new(Query {
conn,
@@ -44,8 +44,8 @@ pub fn graphql_client(conn: &ConnectParams) -> gql_client::Client {
mod test {
use super::connect;
#[test]
fn test_connect() {
let _ = connect().unwrap();
#[tokio::test]
async fn test_connect() {
let _ = connect().await.unwrap();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +1,6 @@
pub mod client;
pub mod gen;
mod client;
mod gen;
mod querybuilder;
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
pub use client::*;
pub use gen::*;

View File

@@ -46,13 +46,13 @@ impl Selection {
}
}
pub fn arg<S>(&self, name: &str, value: S) -> eyre::Result<Selection>
pub fn arg<S>(&self, name: &str, value: S) -> Selection
where
S: Serialize,
{
let mut s = self.clone();
let val = serde_json::to_string(&value)?;
let val = serde_json::to_string(&value).unwrap();
match s.args.as_mut() {
Some(args) => {
@@ -65,7 +65,7 @@ impl Selection {
}
}
Ok(s)
s
}
pub fn build(&self) -> eyre::Result<String> {
@@ -93,25 +93,20 @@ impl Selection {
Ok(fields.join("{") + &"}".repeat(fields.len() - 1))
}
pub fn execute<D>(&self, gql_client: &gql_client::Client) -> eyre::Result<Option<D>>
pub async fn execute<D>(&self, gql_client: &gql_client::Client) -> eyre::Result<D>
where
D: for<'de> Deserialize<'de>,
{
let query = self.build()?;
let basic = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
let resp: Option<serde_json::Value> = match basic.block_on(gql_client.query(&query)) {
let resp: Option<serde_json::Value> = match gql_client.query(&query).await {
Ok(r) => r,
Err(e) => eyre::bail!(e),
};
let resp: Option<D> = self.unpack_resp(resp)?;
Ok(resp)
Ok(resp.unwrap())
}
fn path(&self) -> Vec<Selection> {
@@ -171,10 +166,8 @@ mod tests {
.select("core")
.select("image")
.arg("ref", "alpine")
.unwrap()
.select("file")
.arg("path", "/etc/alpine-release")
.unwrap();
.arg("path", "/etc/alpine-release");
let query = root.build().unwrap();
@@ -190,10 +183,8 @@ mod tests {
.select("core")
.select("image")
.arg("ref", "alpine")
.unwrap()
.select_with_alias("foo", "file")
.arg("path", "/etc/alpine-release")
.unwrap();
.arg("path", "/etc/alpine-release");
let query = root.build().unwrap();
@@ -208,10 +199,8 @@ mod tests {
let root = query()
.select("a")
.arg("arg", "one")
.unwrap()
.select("b")
.arg("arg", "two")
.unwrap();
.arg("arg", "two");
let query = root.build().unwrap();
@@ -222,7 +211,7 @@ mod tests {
fn test_vec_arg() {
let input = vec!["some-string"];
let root = query().select("a").arg("arg", input).unwrap();
let root = query().select("a").arg("arg", input);
let query = root.build().unwrap();
assert_eq!(query, r#"query{a(arg:["some-string"])}"#.to_string())
@@ -232,7 +221,7 @@ mod tests {
fn test_ref_slice_arg() {
let input = &["some-string"];
let root = query().select("a").arg("arg", input).unwrap();
let root = query().select("a").arg("arg", input);
let query = root.build().unwrap();
assert_eq!(query, r#"query{a(arg:["some-string"])}"#.to_string())
@@ -242,7 +231,7 @@ mod tests {
fn test_stringb_arg() {
let input = "some-string".to_string();
let root = query().select("a").arg("arg", input).unwrap();
let root = query().select("a").arg("arg", input);
let query = root.build().unwrap();
assert_eq!(query, r#"query{a(arg:"some-string")}"#.to_string())
@@ -275,7 +264,7 @@ mod tests {
})),
};
let root = query().select("a").arg("arg", input).unwrap();
let root = query().select("a").arg("arg", input);
let query = root.build().unwrap();
assert_eq!(

View File

@@ -1,21 +1,21 @@
use dagger_sdk::client::connect;
use dagger_sdk::gen::ContainerExecOpts;
use dagger_sdk::{connect, ContainerExecOptsBuilder};
#[test]
fn test_example_container() {
let client = connect().unwrap();
#[tokio::test]
async fn test_example_container() {
let client = connect().await.unwrap();
let alpine = client.container(None).from("alpine:3.16.2".into());
let alpine = client.container().from("alpine:3.16.2");
let out = alpine
.exec(Some(ContainerExecOpts {
args: Some(vec!["cat".into(), "/etc/alpine-release".into()]),
stdin: None,
redirect_stdout: None,
redirect_stderr: None,
experimental_privileged_nesting: None,
}))
.stdout();
.exec_opts(
ContainerExecOptsBuilder::default()
.args(vec!["cat", "/etc/alpine-release"])
.build()
.unwrap(),
)
.stdout()
.await
.unwrap();
assert_eq!(out, "3.16.2\n".to_string())
}

View File

@@ -13,11 +13,11 @@ impl Cli {
})
}
pub fn execute(self, args: &[&str]) -> eyre::Result<()> {
pub async fn execute(self, args: &[&str]) -> eyre::Result<()> {
let matches = self.cmd.get_matches_from(args);
match matches.subcommand() {
Some(("generate", args)) => cli_generate::GenerateCommand::exec(args)?,
Some(("generate", args)) => cli_generate::GenerateCommand::exec(args).await?,
_ => eyre::bail!("command missing"),
}

View File

@@ -17,12 +17,12 @@ impl GenerateCommand {
clap::Command::new("generate").arg(Arg::new("output").long("output"))
}
pub fn exec(arg_matches: &ArgMatches) -> eyre::Result<()> {
pub async fn exec(arg_matches: &ArgMatches) -> eyre::Result<()> {
let cfg = Config::default();
let (conn, _proc) = Engine::new().start(&cfg)?;
let (conn, _proc) = Engine::new().start(&cfg).await?;
let session = Session::new();
let req = session.start(&cfg, &conn)?;
let schema = session.schema(req)?;
let schema = session.schema(req).await?;
let code = generate(
schema.into_schema().schema.unwrap(),
Arc::new(RustGenerator {}),

View File

@@ -3,12 +3,15 @@ use cli::Cli;
pub mod cli;
mod cli_generate;
fn main() -> eyre::Result<()> {
#[tokio::main]
async fn main() -> eyre::Result<()> {
color_eyre::install().unwrap();
let args = std::env::args();
let args = args.collect::<Vec<String>>();
let args = args.iter().map(|s| s.as_str()).collect::<Vec<&str>>();
Cli::new()?.execute(args.as_slice())?;
Cli::new()?.execute(args.as_slice()).await?;
Ok(())
}