-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rofl-containers generic ROFL app runtime for containers
- Loading branch information
Showing
5 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "rofl-containers" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
# Oasis SDK. | ||
oasis-runtime-sdk = { path = "../runtime-sdk", features = ["tdx"] } | ||
|
||
# Third party. | ||
base64 = "0.22.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use std::env; | ||
|
||
use base64::prelude::*; | ||
use oasis_runtime_sdk::{cbor, modules::rofl::app::prelude::*}; | ||
|
||
/// A generic container-based ROFL application. | ||
struct ContainersApp; | ||
|
||
#[async_trait] | ||
impl App for ContainersApp { | ||
const VERSION: Version = sdk::version_from_cargo!(); | ||
|
||
fn id() -> AppId { | ||
// Fetch application ID from the ROFL_APP_ID environment variable. | ||
// This would usually be passed via the kernel cmdline. | ||
AppId::from_bech32(&env::var("ROFL_APP_ID").expect("Must configure ROFL_APP_ID.")) | ||
.expect("Corrupted ROFL_APP_ID (must be Bech32-encoded ROFL app ID).") | ||
} | ||
|
||
fn consensus_trust_root() -> Option<TrustRoot> { | ||
// Fetch consensus trust root from the ROFL_CONSENSUS_TRUST_ROOT environment variable. | ||
// This would usually be passed via the kernel cmdline. | ||
let raw_trust_root = env::var("ROFL_CONSENSUS_TRUST_ROOT") | ||
.expect("Must configure ROFL_CONSENSUS_TRUST_ROOT."); | ||
cbor::from_slice( | ||
&BASE64_STANDARD | ||
.decode(raw_trust_root) | ||
.expect("Corrupted ROFL_CONSENSUS_TRUST_ROOT (must be Base64-encoded CBOR)."), | ||
) | ||
.expect("Corrupted ROFL_CONSENSUS_TRUST_ROOT (must be Base64-encoded CBOR).") | ||
} | ||
|
||
async fn run(self: Arc<Self>, _env: Environment<Self>) { | ||
// TODO: Start the REST API server. | ||
} | ||
} | ||
|
||
fn main() { | ||
ContainersApp.start(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters