mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2024-11-09 11:21:51 +01:00
feat: dagger-run support
This commit is contained in:
parent
7d186c477d
commit
0318c3c981
@ -18,7 +18,7 @@ pub fn render_object(funcs: &CommonFunctions, t: &FullType) -> eyre::Result<rust
|
|||||||
Ok(quote! {
|
Ok(quote! {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct $(t.name.pipe(|s| format_name(s))) {
|
pub struct $(t.name.pipe(|s| format_name(s))) {
|
||||||
pub proc: $arc<$child>,
|
pub proc: Option<$arc<$child>>,
|
||||||
pub selection: $selection,
|
pub selection: $selection,
|
||||||
pub graphql_client: $graphql_client
|
pub graphql_client: $graphql_client
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,25 @@ impl Engine {
|
|||||||
pub async fn start(
|
pub async fn start(
|
||||||
&self,
|
&self,
|
||||||
cfg: &Config,
|
cfg: &Config,
|
||||||
) -> eyre::Result<(ConnectParams, tokio::process::Child)> {
|
) -> eyre::Result<(ConnectParams, Option<tokio::process::Child>)> {
|
||||||
tracing::info!("starting dagger-engine");
|
tracing::info!("starting dagger-engine");
|
||||||
|
|
||||||
// TODO: Add from existing session as well
|
if let Ok(conn) = self.from_session_env().await {
|
||||||
self.from_cli(cfg).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,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ pub async fn connect_opts(cfg: Config) -> eyre::Result<DaggerConn> {
|
|||||||
let (conn, proc) = DaggerEngine::new().start(&cfg).await?;
|
let (conn, proc) = DaggerEngine::new().start(&cfg).await?;
|
||||||
|
|
||||||
Ok(Arc::new(Query {
|
Ok(Arc::new(Query {
|
||||||
proc: Arc::new(proc),
|
proc: proc.map(|p| Arc::new(p)),
|
||||||
selection: query(),
|
selection: query(),
|
||||||
graphql_client: Arc::new(DefaultGraphQLClient::new(&conn)),
|
graphql_client: Arc::new(DefaultGraphQLClient::new(&conn)),
|
||||||
}))
|
}))
|
||||||
|
@ -115,7 +115,7 @@ pub struct PipelineLabel {
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct CacheVolume {
|
pub struct CacheVolume {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Option<Arc<Child>>,
|
||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub graphql_client: DynGraphQLClient,
|
pub graphql_client: DynGraphQLClient,
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ impl CacheVolume {
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Container {
|
pub struct Container {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Option<Arc<Child>>,
|
||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub graphql_client: DynGraphQLClient,
|
pub graphql_client: DynGraphQLClient,
|
||||||
}
|
}
|
||||||
@ -1728,7 +1728,7 @@ impl Container {
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Directory {
|
pub struct Directory {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Option<Arc<Child>>,
|
||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub graphql_client: DynGraphQLClient,
|
pub graphql_client: DynGraphQLClient,
|
||||||
}
|
}
|
||||||
@ -2235,7 +2235,7 @@ impl Directory {
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct EnvVariable {
|
pub struct EnvVariable {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Option<Arc<Child>>,
|
||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub graphql_client: DynGraphQLClient,
|
pub graphql_client: DynGraphQLClient,
|
||||||
}
|
}
|
||||||
@ -2256,7 +2256,7 @@ impl EnvVariable {
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct File {
|
pub struct File {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Option<Arc<Child>>,
|
||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub graphql_client: DynGraphQLClient,
|
pub graphql_client: DynGraphQLClient,
|
||||||
}
|
}
|
||||||
@ -2323,7 +2323,7 @@ impl File {
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct GitRef {
|
pub struct GitRef {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Option<Arc<Child>>,
|
||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub graphql_client: DynGraphQLClient,
|
pub graphql_client: DynGraphQLClient,
|
||||||
}
|
}
|
||||||
@ -2382,7 +2382,7 @@ impl GitRef {
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct GitRepository {
|
pub struct GitRepository {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Option<Arc<Child>>,
|
||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub graphql_client: DynGraphQLClient,
|
pub graphql_client: DynGraphQLClient,
|
||||||
}
|
}
|
||||||
@ -2451,7 +2451,7 @@ impl GitRepository {
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Host {
|
pub struct Host {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Option<Arc<Child>>,
|
||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub graphql_client: DynGraphQLClient,
|
pub graphql_client: DynGraphQLClient,
|
||||||
}
|
}
|
||||||
@ -2592,7 +2592,7 @@ impl Host {
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct HostVariable {
|
pub struct HostVariable {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Option<Arc<Child>>,
|
||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub graphql_client: DynGraphQLClient,
|
pub graphql_client: DynGraphQLClient,
|
||||||
}
|
}
|
||||||
@ -2617,7 +2617,7 @@ impl HostVariable {
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Label {
|
pub struct Label {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Option<Arc<Child>>,
|
||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub graphql_client: DynGraphQLClient,
|
pub graphql_client: DynGraphQLClient,
|
||||||
}
|
}
|
||||||
@ -2638,7 +2638,7 @@ impl Label {
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Port {
|
pub struct Port {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Option<Arc<Child>>,
|
||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub graphql_client: DynGraphQLClient,
|
pub graphql_client: DynGraphQLClient,
|
||||||
}
|
}
|
||||||
@ -2665,7 +2665,7 @@ impl Port {
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Project {
|
pub struct Project {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Option<Arc<Child>>,
|
||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub graphql_client: DynGraphQLClient,
|
pub graphql_client: DynGraphQLClient,
|
||||||
}
|
}
|
||||||
@ -2718,7 +2718,7 @@ impl Project {
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Query {
|
pub struct Query {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Option<Arc<Child>>,
|
||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub graphql_client: DynGraphQLClient,
|
pub graphql_client: DynGraphQLClient,
|
||||||
}
|
}
|
||||||
@ -3087,7 +3087,7 @@ impl Query {
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Secret {
|
pub struct Secret {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Option<Arc<Child>>,
|
||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub graphql_client: DynGraphQLClient,
|
pub graphql_client: DynGraphQLClient,
|
||||||
}
|
}
|
||||||
@ -3108,7 +3108,7 @@ impl Secret {
|
|||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Socket {
|
pub struct Socket {
|
||||||
pub proc: Arc<Child>,
|
pub proc: Option<Arc<Child>>,
|
||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub graphql_client: DynGraphQLClient,
|
pub graphql_client: DynGraphQLClient,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user