Skip to content

Commit

Permalink
ExeUnit: pass extra arguments down to runtime (golemfactory#1712)
Browse files Browse the repository at this point in the history
Co-authored-by: nieznanysprawiciel <[email protected]>
  • Loading branch information
mfranciszkiewicz and nieznanysprawiciel authored Nov 26, 2021
1 parent 929fad0 commit c30b3aa
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion exe-unit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ya-exe-unit"
version = "0.1.4"
version = "0.1.5"
authors = ["Golem Factory <[email protected]>"]
edition = "2018"

Expand Down
1 change: 1 addition & 0 deletions exe-unit/examples/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ async fn main() -> anyhow::Result<()> {
agreement,
work_dir: work_dir.clone(),
cache_dir,
runtime_args: Default::default(),
#[cfg(feature = "sgx")]
crypto: init_crypto()?,
};
Expand Down
1 change: 1 addition & 0 deletions exe-unit/examples/transfer_abort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ async fn main() -> anyhow::Result<()> {
agreement,
work_dir,
cache_dir,
runtime_args: Default::default(),
#[cfg(feature = "sgx")]
crypto: init_crypto()?,
};
Expand Down
39 changes: 24 additions & 15 deletions exe-unit/src/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,28 @@ struct Cli {
binary: PathBuf,
#[structopt(flatten)]
supervise: SuperviseCli,
/// Additional runtime arguments
#[structopt(
long,
short,
set = clap::ArgSettings::Global,
number_of_values = 1,
)]
runtime_arg: Vec<String>,
/// Enclave secret key used in secure communication
#[structopt(
long,
env = "EXE_UNIT_SEC_KEY",
hide_env_values = true,
set = clap::ArgSettings::Global,
long,
env = "EXE_UNIT_SEC_KEY",
hide_env_values = true,
set = clap::ArgSettings::Global,
)]
sec_key: Option<String>,
/// Requestor public key used in secure communication
#[structopt(
long,
env = "EXE_UNIT_REQUESTOR_PUB_KEY",
hide_env_values = true,
set = clap::ArgSettings::Global,
long,
env = "EXE_UNIT_REQUESTOR_PUB_KEY",
hide_env_values = true,
set = clap::ArgSettings::Global,
)]
requestor_pub_key: Option<String>,
#[structopt(subcommand)]
Expand All @@ -51,17 +59,17 @@ struct Cli {
struct SuperviseCli {
/// Hardware resources are handled by the runtime
#[structopt(
long = "runtime-managed-hardware",
alias = "cap-handoff",
parse(from_flag = std::ops::Not::not),
set = clap::ArgSettings::Global,
long = "runtime-managed-hardware",
alias = "cap-handoff",
parse(from_flag = std::ops::Not::not),
set = clap::ArgSettings::Global,
)]
hardware: bool,
/// Images are handled by the runtime
#[structopt(
long = "runtime-managed-image",
parse(from_flag = std::ops::Not::not),
set = clap::ArgSettings::Global,
long = "runtime-managed-image",
parse(from_flag = std::ops::Not::not),
set = clap::ArgSettings::Global,
)]
image: bool,
}
Expand Down Expand Up @@ -261,6 +269,7 @@ fn run() -> anyhow::Result<()> {
agreement,
work_dir,
cache_dir,
runtime_args: cli.runtime_arg.clone(),
acl: Default::default(),
credentials: None,
#[cfg(feature = "sgx")]
Expand Down
1 change: 1 addition & 0 deletions exe-unit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ pub struct ExeUnitContext {
pub agreement: Agreement,
pub work_dir: PathBuf,
pub cache_dir: PathBuf,
pub runtime_args: Vec<String>,
pub acl: Acl,
pub credentials: Option<Credentials>,
#[cfg(feature = "sgx")]
Expand Down
2 changes: 2 additions & 0 deletions exe-unit/src/runtime/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ impl RuntimeProcess {
}
}

args.args(self.ctx.runtime_args.iter());

Ok(args)
}
}
Expand Down

0 comments on commit c30b3aa

Please sign in to comment.