mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2025-08-17 20:53:29 +02:00
Compare commits
8 Commits
dagger-sdk
...
dagger-sdk
Author | SHA1 | Date | |
---|---|---|---|
40ece05140
|
|||
2a29a66217 | |||
7d186c477d | |||
cf92018a1e | |||
09fd7c89b8 | |||
e39ee28ec0 | |||
4dac924783 | |||
eb7470c604 |
8
.github/workflows/ci.yaml
vendored
8
.github/workflows/ci.yaml
vendored
@@ -8,7 +8,6 @@ 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
|
||||
@@ -28,5 +27,10 @@ jobs:
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2.0.0
|
||||
-
|
||||
name: Expose GitHub Runtime
|
||||
uses: crazy-max/ghaction-github-runtime@v2
|
||||
- name: Run dagger [CI]
|
||||
run: cargo run -p ci -- pr
|
||||
run: |
|
||||
export _EXPERIMENTAL_DAGGER_CACHE_CONFIG="type=gha,mode=max,url=$ACTIONS_CACHE_URL,token=$ACTIONS_RUNTIME_TOKEN"
|
||||
cargo run -p ci -- pr
|
||||
|
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -317,7 +317,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dagger-core"
|
||||
version = "0.2.10"
|
||||
version = "0.2.11"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64",
|
||||
@@ -341,7 +341,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "dagger-sdk"
|
||||
version = "0.2.21"
|
||||
version = "0.2.22"
|
||||
dependencies = [
|
||||
"dagger-core",
|
||||
"derive_builder",
|
||||
|
@@ -8,6 +8,6 @@ edition = "2021"
|
||||
[dependencies]
|
||||
clap = "4.1.6"
|
||||
color-eyre = "0.6.2"
|
||||
dagger-sdk = { path = "../crates/dagger-sdk/", version = "^0.2.21" }
|
||||
dagger-sdk = { path = "../crates/dagger-sdk/", version = "^0.2.22" }
|
||||
eyre = "0.6.8"
|
||||
tokio = { version = "1.25.0", features = ["full"] }
|
||||
|
@@ -18,7 +18,7 @@ pub fn render_object(funcs: &CommonFunctions, t: &FullType) -> eyre::Result<rust
|
||||
Ok(quote! {
|
||||
#[derive(Clone)]
|
||||
pub struct $(t.name.pipe(|s| format_name(s))) {
|
||||
pub proc: $arc<$child>,
|
||||
pub proc: Option<$arc<$child>>,
|
||||
pub selection: $selection,
|
||||
pub graphql_client: $graphql_client
|
||||
}
|
||||
|
@@ -5,6 +5,33 @@ 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.11 (2023-04-29)
|
||||
|
||||
### New Features
|
||||
|
||||
- <csr-id-2a29a66217fa4d6c530ea1ce670c8836383e7051/> dagger-run support
|
||||
- <csr-id-eb7470c604169d1a15976078c0889d5cc7011257/> update to dagger-5.1
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 2 commits contributed to the release.
|
||||
- 4 days passed between releases.
|
||||
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
|
||||
- 0 issues like '(#ID)' were seen in commit messages
|
||||
|
||||
### Commit Details
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- dagger-run support ([`2a29a66`](https://github.com/kjuulh/dagger-sdk/commit/2a29a66217fa4d6c530ea1ce670c8836383e7051))
|
||||
- update to dagger-5.1 ([`eb7470c`](https://github.com/kjuulh/dagger-sdk/commit/eb7470c604169d1a15976078c0889d5cc7011257))
|
||||
</details>
|
||||
|
||||
## v0.2.10 (2023-04-25)
|
||||
|
||||
### Bug Fixes
|
||||
@@ -15,7 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 1 commit contributed to the release.
|
||||
- 2 commits contributed to the release.
|
||||
- 21 days passed between releases.
|
||||
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
|
||||
- 0 issues like '(#ID)' were seen in commit messages
|
||||
@@ -27,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- Release dagger-core v0.2.10 ([`8011c42`](https://github.com/kjuulh/dagger-sdk/commit/8011c42dc077d101b1bccaf231fac17636dd249d))
|
||||
- delete other files/folder in downloads: #57 ([`9d3c21d`](https://github.com/kjuulh/dagger-sdk/commit/9d3c21d16b4a64eb7a7b1888365a4c4ea56d7225))
|
||||
</details>
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "dagger-core"
|
||||
version = "0.2.10"
|
||||
version = "0.2.11"
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
license-file = "LICENSE.MIT"
|
||||
|
@@ -89,6 +89,7 @@ impl InnerCliSession {
|
||||
while let Ok(Some(line)) = stdout_bufr.next_line().await {
|
||||
if let Ok(conn) = serde_json::from_str::<ConnectParams>(&line) {
|
||||
sender.send(conn).await.unwrap();
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(logger) = &logger {
|
||||
|
@@ -23,10 +23,25 @@ impl Engine {
|
||||
pub async fn start(
|
||||
&self,
|
||||
cfg: &Config,
|
||||
) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
|
||||
) -> eyre::Result<(ConnectParams, Option<tokio::process::Child>)> {
|
||||
tracing::info!("starting dagger-engine");
|
||||
|
||||
// TODO: Add from existing session as well
|
||||
self.from_cli(cfg).await
|
||||
if let Ok(conn) = self.from_session_env().await {
|
||||
return Ok((conn, None));
|
||||
}
|
||||
|
||||
let (conn, proc) = self.from_cli(cfg).await?;
|
||||
|
||||
Ok((conn, Some(proc)))
|
||||
}
|
||||
|
||||
async fn from_session_env(&self) -> eyre::Result<ConnectParams> {
|
||||
let port = std::env::var("DAGGER_SESSION_PORT").map(|p| p.parse::<u64>())??;
|
||||
let token = std::env::var("DAGGER_SESSION_TOKEN")?;
|
||||
|
||||
Ok(ConnectParams {
|
||||
port,
|
||||
session_token: token,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#![deny(warnings)]
|
||||
|
||||
pub const DAGGER_ENGINE_VERSION: &'static str = "0.4.2";
|
||||
pub const DAGGER_ENGINE_VERSION: &'static str = "0.5.1";
|
||||
|
||||
pub mod cli_session;
|
||||
pub mod config;
|
||||
|
@@ -6,8 +6,37 @@ 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.22 (2023-04-29)
|
||||
|
||||
### New Features
|
||||
|
||||
- <csr-id-2a29a66217fa4d6c530ea1ce670c8836383e7051/> dagger-run support
|
||||
- <csr-id-eb7470c604169d1a15976078c0889d5cc7011257/> update to dagger-5.1
|
||||
|
||||
### Commit Statistics
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 2 commits contributed to the release.
|
||||
- 4 days passed between releases.
|
||||
- 2 commits were understood as [conventional](https://www.conventionalcommits.org).
|
||||
- 0 issues like '(#ID)' were seen in commit messages
|
||||
|
||||
### Commit Details
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- dagger-run support ([`2a29a66`](https://github.com/kjuulh/dagger-sdk/commit/2a29a66217fa4d6c530ea1ce670c8836383e7051))
|
||||
- update to dagger-5.1 ([`eb7470c`](https://github.com/kjuulh/dagger-sdk/commit/eb7470c604169d1a15976078c0889d5cc7011257))
|
||||
</details>
|
||||
|
||||
## v0.2.21 (2023-04-25)
|
||||
|
||||
<csr-id-09881ee39bdfb9201d104e4679a51c3b76b5fe27/>
|
||||
|
||||
### Chore
|
||||
|
||||
- <csr-id-09881ee39bdfb9201d104e4679a51c3b76b5fe27/> add new dagger-core-version
|
||||
@@ -16,7 +45,7 @@ and this project adheres to
|
||||
|
||||
<csr-read-only-do-not-edit/>
|
||||
|
||||
- 1 commit contributed to the release.
|
||||
- 2 commits contributed to the release.
|
||||
- 21 days passed between releases.
|
||||
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
|
||||
- 0 issues like '(#ID)' were seen in commit messages
|
||||
@@ -28,6 +57,7 @@ and this project adheres to
|
||||
<details><summary>view details</summary>
|
||||
|
||||
* **Uncategorized**
|
||||
- Release dagger-sdk v0.2.21 ([`6937ef0`](https://github.com/kjuulh/dagger-sdk/commit/6937ef0ace797315013513aa7e2af39a9206a738))
|
||||
- add new dagger-core-version ([`09881ee`](https://github.com/kjuulh/dagger-sdk/commit/09881ee39bdfb9201d104e4679a51c3b76b5fe27))
|
||||
</details>
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "dagger-sdk"
|
||||
version = "0.2.21"
|
||||
version = "0.2.22"
|
||||
edition = "2021"
|
||||
readme = "README.md"
|
||||
license-file = "LICENSE.MIT"
|
||||
@@ -11,7 +11,7 @@ publish = true
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
dagger-core = { workspace = true, version = "0.2.10" }
|
||||
dagger-core = { workspace = true, version = "^0.2.11" }
|
||||
|
||||
eyre = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
|
@@ -7,7 +7,7 @@ async fn main() -> eyre::Result<()> {
|
||||
let host_source_dir = client.host().directory_opts(
|
||||
"./examples/caching/app",
|
||||
dagger_sdk::HostDirectoryOptsBuilder::default()
|
||||
.exclude(vec!["node_modules", "ci/"])
|
||||
.exclude(vec!["node_modules/", "ci/"])
|
||||
.build()?,
|
||||
);
|
||||
|
||||
|
@@ -21,7 +21,7 @@ pub async fn connect_opts(cfg: Config) -> eyre::Result<DaggerConn> {
|
||||
let (conn, proc) = DaggerEngine::new().start(&cfg).await?;
|
||||
|
||||
Ok(Arc::new(Query {
|
||||
proc: Arc::new(proc),
|
||||
proc: proc.map(|p| Arc::new(p)),
|
||||
selection: query(),
|
||||
graphql_client: Arc::new(DefaultGraphQLClient::new(&conn)),
|
||||
}))
|
||||
|
@@ -115,7 +115,7 @@ pub struct PipelineLabel {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct CacheVolume {
|
||||
pub proc: Arc<Child>,
|
||||
pub proc: Option<Arc<Child>>,
|
||||
pub selection: Selection,
|
||||
pub graphql_client: DynGraphQLClient,
|
||||
}
|
||||
@@ -129,7 +129,7 @@ impl CacheVolume {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct Container {
|
||||
pub proc: Arc<Child>,
|
||||
pub proc: Option<Arc<Child>>,
|
||||
pub selection: Selection,
|
||||
pub graphql_client: DynGraphQLClient,
|
||||
}
|
||||
@@ -143,6 +143,10 @@ pub struct ContainerBuildOpts<'a> {
|
||||
/// Default: './Dockerfile'.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub dockerfile: Option<&'a str>,
|
||||
/// Secrets to pass to the build.
|
||||
/// They will be mounted at /run/secrets/[secret-name].
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub secrets: Option<Vec<SecretId>>,
|
||||
/// Target build stage to build.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub target: Option<&'a str>,
|
||||
@@ -184,6 +188,13 @@ pub struct ContainerExportOpts {
|
||||
pub platform_variants: Option<Vec<ContainerId>>,
|
||||
}
|
||||
#[derive(Builder, Debug, PartialEq)]
|
||||
pub struct ContainerImportOpts<'a> {
|
||||
/// Identifies the tag to import from the archive, if the archive bundles
|
||||
/// multiple tags.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub tag: Option<&'a str>,
|
||||
}
|
||||
#[derive(Builder, Debug, PartialEq)]
|
||||
pub struct ContainerPipelineOpts<'a> {
|
||||
/// Pipeline description.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
@@ -213,6 +224,11 @@ pub struct ContainerWithDirectoryOpts<'a> {
|
||||
/// Patterns to include in the written directory (e.g., ["*.go", "go.mod", "go.sum"]).
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub include: Option<Vec<&'a str>>,
|
||||
/// A user:group to set for the directory and its contents.
|
||||
/// The user and group can either be an ID (1000:1000) or a name (foo:bar).
|
||||
/// If the group is omitted, it defaults to the same as the user.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub owner: Option<&'a str>,
|
||||
}
|
||||
#[derive(Builder, Debug, PartialEq)]
|
||||
pub struct ContainerWithExecOpts<'a> {
|
||||
@@ -233,6 +249,9 @@ pub struct ContainerWithExecOpts<'a> {
|
||||
/// Redirect the command's standard output to a file in the container (e.g., "/tmp/stdout").
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub redirect_stdout: Option<&'a str>,
|
||||
/// If the container has an entrypoint, ignore it for args rather than using it to wrap them.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub skip_entrypoint: Option<bool>,
|
||||
/// Content to write to the command's standard input before closing (e.g., "Hello world").
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub stdin: Option<&'a str>,
|
||||
@@ -247,14 +266,27 @@ pub struct ContainerWithExposedPortOpts<'a> {
|
||||
pub protocol: Option<NetworkProtocol>,
|
||||
}
|
||||
#[derive(Builder, Debug, PartialEq)]
|
||||
pub struct ContainerWithFileOpts {
|
||||
pub struct ContainerWithFileOpts<'a> {
|
||||
/// A user:group to set for the file.
|
||||
/// The user and group can either be an ID (1000:1000) or a name (foo:bar).
|
||||
/// If the group is omitted, it defaults to the same as the user.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub owner: Option<&'a str>,
|
||||
/// Permission given to the copied file (e.g., 0600).
|
||||
/// Default: 0644.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub permissions: Option<isize>,
|
||||
}
|
||||
#[derive(Builder, Debug, PartialEq)]
|
||||
pub struct ContainerWithMountedCacheOpts {
|
||||
pub struct ContainerWithMountedCacheOpts<'a> {
|
||||
/// A user:group to set for the mounted cache directory.
|
||||
/// Note that this changes the ownership of the specified mount along with the
|
||||
/// initial filesystem provided by source (if any). It does not have any effect
|
||||
/// if/when the cache has already been created.
|
||||
/// The user and group can either be an ID (1000:1000) or a name (foo:bar).
|
||||
/// If the group is omitted, it defaults to the same as the user.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub owner: Option<&'a str>,
|
||||
/// Sharing mode of the cache volume.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub sharing: Option<CacheSharingMode>,
|
||||
@@ -263,16 +295,53 @@ pub struct ContainerWithMountedCacheOpts {
|
||||
pub source: Option<DirectoryId>,
|
||||
}
|
||||
#[derive(Builder, Debug, PartialEq)]
|
||||
pub struct ContainerWithMountedDirectoryOpts<'a> {
|
||||
/// A user:group to set for the mounted directory and its contents.
|
||||
/// The user and group can either be an ID (1000:1000) or a name (foo:bar).
|
||||
/// If the group is omitted, it defaults to the same as the user.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub owner: Option<&'a str>,
|
||||
}
|
||||
#[derive(Builder, Debug, PartialEq)]
|
||||
pub struct ContainerWithMountedFileOpts<'a> {
|
||||
/// A user or user:group to set for the mounted file.
|
||||
/// The user and group can either be an ID (1000:1000) or a name (foo:bar).
|
||||
/// If the group is omitted, it defaults to the same as the user.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub owner: Option<&'a str>,
|
||||
}
|
||||
#[derive(Builder, Debug, PartialEq)]
|
||||
pub struct ContainerWithMountedSecretOpts<'a> {
|
||||
/// A user:group to set for the mounted secret.
|
||||
/// The user and group can either be an ID (1000:1000) or a name (foo:bar).
|
||||
/// If the group is omitted, it defaults to the same as the user.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub owner: Option<&'a str>,
|
||||
}
|
||||
#[derive(Builder, Debug, PartialEq)]
|
||||
pub struct ContainerWithNewFileOpts<'a> {
|
||||
/// Content of the file to write (e.g., "Hello world!").
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub contents: Option<&'a str>,
|
||||
/// A user:group to set for the file.
|
||||
/// The user and group can either be an ID (1000:1000) or a name (foo:bar).
|
||||
/// If the group is omitted, it defaults to the same as the user.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub owner: Option<&'a str>,
|
||||
/// Permission given to the written file (e.g., 0600).
|
||||
/// Default: 0644.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub permissions: Option<isize>,
|
||||
}
|
||||
#[derive(Builder, Debug, PartialEq)]
|
||||
pub struct ContainerWithUnixSocketOpts<'a> {
|
||||
/// A user:group to set for the mounted socket.
|
||||
/// The user and group can either be an ID (1000:1000) or a name (foo:bar).
|
||||
/// If the group is omitted, it defaults to the same as the user.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub owner: Option<&'a str>,
|
||||
}
|
||||
#[derive(Builder, Debug, PartialEq)]
|
||||
pub struct ContainerWithoutExposedPortOpts {
|
||||
/// Port protocol to unexpose
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
@@ -317,6 +386,9 @@ impl Container {
|
||||
if let Some(target) = opts.target {
|
||||
query = query.arg("target", target);
|
||||
}
|
||||
if let Some(secrets) = opts.secrets {
|
||||
query = query.arg("secrets", secrets);
|
||||
}
|
||||
|
||||
return Container {
|
||||
proc: self.proc.clone(),
|
||||
@@ -458,7 +530,7 @@ impl Container {
|
||||
};
|
||||
}
|
||||
/// Exit code of the last executed command. Zero means success.
|
||||
/// Errors if no command has been executed.
|
||||
/// Will execute default command if none is set, or error if there's no default.
|
||||
pub async fn exit_code(&self) -> eyre::Result<isize> {
|
||||
let query = self.selection.select("exitCode");
|
||||
|
||||
@@ -579,6 +651,48 @@ impl Container {
|
||||
|
||||
query.execute(self.graphql_client.clone()).await
|
||||
}
|
||||
/// Reads the container from an OCI tarball.
|
||||
/// NOTE: this involves unpacking the tarball to an OCI store on the host at
|
||||
/// $XDG_CACHE_DIR/dagger/oci. This directory can be removed whenever you like.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `source` - File to read the container from.
|
||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||
pub fn import(&self, source: FileId) -> Container {
|
||||
let mut query = self.selection.select("import");
|
||||
|
||||
query = query.arg("source", source);
|
||||
|
||||
return Container {
|
||||
proc: self.proc.clone(),
|
||||
selection: query,
|
||||
graphql_client: self.graphql_client.clone(),
|
||||
};
|
||||
}
|
||||
|
||||
/// Reads the container from an OCI tarball.
|
||||
/// NOTE: this involves unpacking the tarball to an OCI store on the host at
|
||||
/// $XDG_CACHE_DIR/dagger/oci. This directory can be removed whenever you like.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `source` - File to read the container from.
|
||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||
pub fn import_opts<'a>(&self, source: FileId, opts: ContainerImportOpts<'a>) -> Container {
|
||||
let mut query = self.selection.select("import");
|
||||
|
||||
query = query.arg("source", source);
|
||||
if let Some(tag) = opts.tag {
|
||||
query = query.arg("tag", tag);
|
||||
}
|
||||
|
||||
return Container {
|
||||
proc: self.proc.clone(),
|
||||
selection: query,
|
||||
graphql_client: self.graphql_client.clone(),
|
||||
};
|
||||
}
|
||||
/// Retrieves the value of the specified label.
|
||||
pub async fn label(&self, name: impl Into<String>) -> eyre::Result<String> {
|
||||
let mut query = self.selection.select("label");
|
||||
@@ -707,14 +821,14 @@ impl Container {
|
||||
};
|
||||
}
|
||||
/// The error stream of the last executed command.
|
||||
/// Errors if no command has been executed.
|
||||
/// Will execute default command if none is set, or error if there's no default.
|
||||
pub async fn stderr(&self) -> eyre::Result<String> {
|
||||
let query = self.selection.select("stderr");
|
||||
|
||||
query.execute(self.graphql_client.clone()).await
|
||||
}
|
||||
/// The output stream of the last executed command.
|
||||
/// Errors if no command has been executed.
|
||||
/// Will execute default command if none is set, or error if there's no default.
|
||||
pub async fn stdout(&self) -> eyre::Result<String> {
|
||||
let query = self.selection.select("stdout");
|
||||
|
||||
@@ -802,6 +916,9 @@ impl Container {
|
||||
if let Some(include) = opts.include {
|
||||
query = query.arg("include", include);
|
||||
}
|
||||
if let Some(owner) = opts.owner {
|
||||
query = query.arg("owner", owner);
|
||||
}
|
||||
|
||||
return Container {
|
||||
proc: self.proc.clone(),
|
||||
@@ -855,6 +972,8 @@ impl Container {
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `args` - Command to run instead of the container's default command (e.g., ["run", "main.go"]).
|
||||
///
|
||||
/// If empty, the container's default command is used.
|
||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||
pub fn with_exec(&self, args: Vec<impl Into<String>>) -> Container {
|
||||
let mut query = self.selection.select("withExec");
|
||||
@@ -876,6 +995,8 @@ impl Container {
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `args` - Command to run instead of the container's default command (e.g., ["run", "main.go"]).
|
||||
///
|
||||
/// If empty, the container's default command is used.
|
||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||
pub fn with_exec_opts<'a>(
|
||||
&self,
|
||||
@@ -888,6 +1009,9 @@ impl Container {
|
||||
"args",
|
||||
args.into_iter().map(|i| i.into()).collect::<Vec<String>>(),
|
||||
);
|
||||
if let Some(skip_entrypoint) = opts.skip_entrypoint {
|
||||
query = query.arg("skipEntrypoint", skip_entrypoint);
|
||||
}
|
||||
if let Some(stdin) = opts.stdin {
|
||||
query = query.arg("stdin", stdin);
|
||||
}
|
||||
@@ -1005,11 +1129,11 @@ impl Container {
|
||||
/// * `path` - Location of the copied file (e.g., "/tmp/file.txt").
|
||||
/// * `source` - Identifier of the file to copy.
|
||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||
pub fn with_file_opts(
|
||||
pub fn with_file_opts<'a>(
|
||||
&self,
|
||||
path: impl Into<String>,
|
||||
source: FileId,
|
||||
opts: ContainerWithFileOpts,
|
||||
opts: ContainerWithFileOpts<'a>,
|
||||
) -> Container {
|
||||
let mut query = self.selection.select("withFile");
|
||||
|
||||
@@ -1018,6 +1142,9 @@ impl Container {
|
||||
if let Some(permissions) = opts.permissions {
|
||||
query = query.arg("permissions", permissions);
|
||||
}
|
||||
if let Some(owner) = opts.owner {
|
||||
query = query.arg("owner", owner);
|
||||
}
|
||||
|
||||
return Container {
|
||||
proc: self.proc.clone(),
|
||||
@@ -1070,11 +1197,11 @@ impl Container {
|
||||
/// * `path` - Location of the cache directory (e.g., "/cache/node_modules").
|
||||
/// * `cache` - Identifier of the cache volume to mount.
|
||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||
pub fn with_mounted_cache_opts(
|
||||
pub fn with_mounted_cache_opts<'a>(
|
||||
&self,
|
||||
path: impl Into<String>,
|
||||
cache: CacheId,
|
||||
opts: ContainerWithMountedCacheOpts,
|
||||
opts: ContainerWithMountedCacheOpts<'a>,
|
||||
) -> Container {
|
||||
let mut query = self.selection.select("withMountedCache");
|
||||
|
||||
@@ -1086,6 +1213,9 @@ impl Container {
|
||||
if let Some(sharing) = opts.sharing {
|
||||
query = query.arg_enum("sharing", sharing);
|
||||
}
|
||||
if let Some(owner) = opts.owner {
|
||||
query = query.arg("owner", owner);
|
||||
}
|
||||
|
||||
return Container {
|
||||
proc: self.proc.clone(),
|
||||
@@ -1099,6 +1229,7 @@ impl Container {
|
||||
///
|
||||
/// * `path` - Location of the mounted directory (e.g., "/mnt/directory").
|
||||
/// * `source` - Identifier of the mounted directory.
|
||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||
pub fn with_mounted_directory(
|
||||
&self,
|
||||
path: impl Into<String>,
|
||||
@@ -1115,12 +1246,41 @@ impl Container {
|
||||
graphql_client: self.graphql_client.clone(),
|
||||
};
|
||||
}
|
||||
|
||||
/// Retrieves this container plus a directory mounted at the given path.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `path` - Location of the mounted directory (e.g., "/mnt/directory").
|
||||
/// * `source` - Identifier of the mounted directory.
|
||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||
pub fn with_mounted_directory_opts<'a>(
|
||||
&self,
|
||||
path: impl Into<String>,
|
||||
source: DirectoryId,
|
||||
opts: ContainerWithMountedDirectoryOpts<'a>,
|
||||
) -> Container {
|
||||
let mut query = self.selection.select("withMountedDirectory");
|
||||
|
||||
query = query.arg("path", path.into());
|
||||
query = query.arg("source", source);
|
||||
if let Some(owner) = opts.owner {
|
||||
query = query.arg("owner", owner);
|
||||
}
|
||||
|
||||
return Container {
|
||||
proc: self.proc.clone(),
|
||||
selection: query,
|
||||
graphql_client: self.graphql_client.clone(),
|
||||
};
|
||||
}
|
||||
/// Retrieves this container plus a file mounted at the given path.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `path` - Location of the mounted file (e.g., "/tmp/file.txt").
|
||||
/// * `source` - Identifier of the mounted file.
|
||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||
pub fn with_mounted_file(&self, path: impl Into<String>, source: FileId) -> Container {
|
||||
let mut query = self.selection.select("withMountedFile");
|
||||
|
||||
@@ -1133,12 +1293,41 @@ impl Container {
|
||||
graphql_client: self.graphql_client.clone(),
|
||||
};
|
||||
}
|
||||
|
||||
/// Retrieves this container plus a file mounted at the given path.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `path` - Location of the mounted file (e.g., "/tmp/file.txt").
|
||||
/// * `source` - Identifier of the mounted file.
|
||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||
pub fn with_mounted_file_opts<'a>(
|
||||
&self,
|
||||
path: impl Into<String>,
|
||||
source: FileId,
|
||||
opts: ContainerWithMountedFileOpts<'a>,
|
||||
) -> Container {
|
||||
let mut query = self.selection.select("withMountedFile");
|
||||
|
||||
query = query.arg("path", path.into());
|
||||
query = query.arg("source", source);
|
||||
if let Some(owner) = opts.owner {
|
||||
query = query.arg("owner", owner);
|
||||
}
|
||||
|
||||
return Container {
|
||||
proc: self.proc.clone(),
|
||||
selection: query,
|
||||
graphql_client: self.graphql_client.clone(),
|
||||
};
|
||||
}
|
||||
/// Retrieves this container plus a secret mounted into a file at the given path.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `path` - Location of the secret file (e.g., "/tmp/secret.txt").
|
||||
/// * `source` - Identifier of the secret to mount.
|
||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||
pub fn with_mounted_secret(&self, path: impl Into<String>, source: SecretId) -> Container {
|
||||
let mut query = self.selection.select("withMountedSecret");
|
||||
|
||||
@@ -1151,6 +1340,34 @@ impl Container {
|
||||
graphql_client: self.graphql_client.clone(),
|
||||
};
|
||||
}
|
||||
|
||||
/// Retrieves this container plus a secret mounted into a file at the given path.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `path` - Location of the secret file (e.g., "/tmp/secret.txt").
|
||||
/// * `source` - Identifier of the secret to mount.
|
||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||
pub fn with_mounted_secret_opts<'a>(
|
||||
&self,
|
||||
path: impl Into<String>,
|
||||
source: SecretId,
|
||||
opts: ContainerWithMountedSecretOpts<'a>,
|
||||
) -> Container {
|
||||
let mut query = self.selection.select("withMountedSecret");
|
||||
|
||||
query = query.arg("path", path.into());
|
||||
query = query.arg("source", source);
|
||||
if let Some(owner) = opts.owner {
|
||||
query = query.arg("owner", owner);
|
||||
}
|
||||
|
||||
return Container {
|
||||
proc: self.proc.clone(),
|
||||
selection: query,
|
||||
graphql_client: self.graphql_client.clone(),
|
||||
};
|
||||
}
|
||||
/// Retrieves this container plus a temporary directory mounted at the given path.
|
||||
///
|
||||
/// # Arguments
|
||||
@@ -1205,6 +1422,9 @@ impl Container {
|
||||
if let Some(permissions) = opts.permissions {
|
||||
query = query.arg("permissions", permissions);
|
||||
}
|
||||
if let Some(owner) = opts.owner {
|
||||
query = query.arg("owner", owner);
|
||||
}
|
||||
|
||||
return Container {
|
||||
proc: self.proc.clone(),
|
||||
@@ -1268,7 +1488,9 @@ impl Container {
|
||||
graphql_client: self.graphql_client.clone(),
|
||||
};
|
||||
}
|
||||
/// Establish a runtime dependency on a service. The service will be started automatically when needed and detached when it is no longer needed.
|
||||
/// Establish a runtime dependency on a service.
|
||||
/// The service will be started automatically when needed and detached when it is
|
||||
/// no longer needed, executing the default command if none is set.
|
||||
/// The service will be reachable from the container via the provided hostname alias.
|
||||
/// The service dependency will also convey to any files or directories produced by the container.
|
||||
/// Currently experimental; set _EXPERIMENTAL_DAGGER_SERVICES_DNS=0 to disable.
|
||||
@@ -1299,6 +1521,7 @@ impl Container {
|
||||
///
|
||||
/// * `path` - Location of the forwarded Unix socket (e.g., "/tmp/socket").
|
||||
/// * `source` - Identifier of the socket to forward.
|
||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||
pub fn with_unix_socket(&self, path: impl Into<String>, source: SocketId) -> Container {
|
||||
let mut query = self.selection.select("withUnixSocket");
|
||||
|
||||
@@ -1311,6 +1534,34 @@ impl Container {
|
||||
graphql_client: self.graphql_client.clone(),
|
||||
};
|
||||
}
|
||||
|
||||
/// Retrieves this container plus a socket forwarded to the given Unix socket path.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `path` - Location of the forwarded Unix socket (e.g., "/tmp/socket").
|
||||
/// * `source` - Identifier of the socket to forward.
|
||||
/// * `opt` - optional argument, see inner type for documentation, use <func>_opts to use
|
||||
pub fn with_unix_socket_opts<'a>(
|
||||
&self,
|
||||
path: impl Into<String>,
|
||||
source: SocketId,
|
||||
opts: ContainerWithUnixSocketOpts<'a>,
|
||||
) -> Container {
|
||||
let mut query = self.selection.select("withUnixSocket");
|
||||
|
||||
query = query.arg("path", path.into());
|
||||
query = query.arg("source", source);
|
||||
if let Some(owner) = opts.owner {
|
||||
query = query.arg("owner", owner);
|
||||
}
|
||||
|
||||
return Container {
|
||||
proc: self.proc.clone(),
|
||||
selection: query,
|
||||
graphql_client: self.graphql_client.clone(),
|
||||
};
|
||||
}
|
||||
/// Retrieves this container with a different command user.
|
||||
///
|
||||
/// # Arguments
|
||||
@@ -1477,7 +1728,7 @@ impl Container {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct Directory {
|
||||
pub proc: Arc<Child>,
|
||||
pub proc: Option<Arc<Child>>,
|
||||
pub selection: Selection,
|
||||
pub graphql_client: DynGraphQLClient,
|
||||
}
|
||||
@@ -1494,6 +1745,10 @@ pub struct DirectoryDockerBuildOpts<'a> {
|
||||
/// The platform to build.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub platform: Option<Platform>,
|
||||
/// Secrets to pass to the build.
|
||||
/// They will be mounted at /run/secrets/[secret-name].
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub secrets: Option<Vec<SecretId>>,
|
||||
/// Target build stage to build.
|
||||
#[builder(setter(into, strip_option), default)]
|
||||
pub target: Option<&'a str>,
|
||||
@@ -1612,6 +1867,9 @@ impl Directory {
|
||||
if let Some(target) = opts.target {
|
||||
query = query.arg("target", target);
|
||||
}
|
||||
if let Some(secrets) = opts.secrets {
|
||||
query = query.arg("secrets", secrets);
|
||||
}
|
||||
|
||||
return Container {
|
||||
proc: self.proc.clone(),
|
||||
@@ -1977,7 +2235,7 @@ impl Directory {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct EnvVariable {
|
||||
pub proc: Arc<Child>,
|
||||
pub proc: Option<Arc<Child>>,
|
||||
pub selection: Selection,
|
||||
pub graphql_client: DynGraphQLClient,
|
||||
}
|
||||
@@ -1998,7 +2256,7 @@ impl EnvVariable {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct File {
|
||||
pub proc: Arc<Child>,
|
||||
pub proc: Option<Arc<Child>>,
|
||||
pub selection: Selection,
|
||||
pub graphql_client: DynGraphQLClient,
|
||||
}
|
||||
@@ -2065,7 +2323,7 @@ impl File {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct GitRef {
|
||||
pub proc: Arc<Child>,
|
||||
pub proc: Option<Arc<Child>>,
|
||||
pub selection: Selection,
|
||||
pub graphql_client: DynGraphQLClient,
|
||||
}
|
||||
@@ -2124,7 +2382,7 @@ impl GitRef {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct GitRepository {
|
||||
pub proc: Arc<Child>,
|
||||
pub proc: Option<Arc<Child>>,
|
||||
pub selection: Selection,
|
||||
pub graphql_client: DynGraphQLClient,
|
||||
}
|
||||
@@ -2193,7 +2451,7 @@ impl GitRepository {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct Host {
|
||||
pub proc: Arc<Child>,
|
||||
pub proc: Option<Arc<Child>>,
|
||||
pub selection: Selection,
|
||||
pub graphql_client: DynGraphQLClient,
|
||||
}
|
||||
@@ -2334,7 +2592,7 @@ impl Host {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct HostVariable {
|
||||
pub proc: Arc<Child>,
|
||||
pub proc: Option<Arc<Child>>,
|
||||
pub selection: Selection,
|
||||
pub graphql_client: DynGraphQLClient,
|
||||
}
|
||||
@@ -2359,7 +2617,7 @@ impl HostVariable {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct Label {
|
||||
pub proc: Arc<Child>,
|
||||
pub proc: Option<Arc<Child>>,
|
||||
pub selection: Selection,
|
||||
pub graphql_client: DynGraphQLClient,
|
||||
}
|
||||
@@ -2380,7 +2638,7 @@ impl Label {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct Port {
|
||||
pub proc: Arc<Child>,
|
||||
pub proc: Option<Arc<Child>>,
|
||||
pub selection: Selection,
|
||||
pub graphql_client: DynGraphQLClient,
|
||||
}
|
||||
@@ -2407,7 +2665,7 @@ impl Port {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct Project {
|
||||
pub proc: Arc<Child>,
|
||||
pub proc: Option<Arc<Child>>,
|
||||
pub selection: Selection,
|
||||
pub graphql_client: DynGraphQLClient,
|
||||
}
|
||||
@@ -2460,7 +2718,7 @@ impl Project {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct Query {
|
||||
pub proc: Arc<Child>,
|
||||
pub proc: Option<Arc<Child>>,
|
||||
pub selection: Selection,
|
||||
pub graphql_client: DynGraphQLClient,
|
||||
}
|
||||
@@ -2829,7 +3087,7 @@ impl Query {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct Secret {
|
||||
pub proc: Arc<Child>,
|
||||
pub proc: Option<Arc<Child>>,
|
||||
pub selection: Selection,
|
||||
pub graphql_client: DynGraphQLClient,
|
||||
}
|
||||
@@ -2850,7 +3108,7 @@ impl Secret {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct Socket {
|
||||
pub proc: Arc<Child>,
|
||||
pub proc: Option<Arc<Child>>,
|
||||
pub selection: Selection,
|
||||
pub graphql_client: DynGraphQLClient,
|
||||
}
|
||||
|
Reference in New Issue
Block a user