Skip to content

Commit

Permalink
Merge pull request #152 from vdice/ref/update-bindle
Browse files Browse the repository at this point in the history
ref(*): update bindle dependency and usage
  • Loading branch information
vdice committed Feb 1, 2022
2 parents 624b23f + fa13832 commit 4d261cf
Show file tree
Hide file tree
Showing 13 changed files with 645 additions and 170 deletions.
778 changes: 621 additions & 157 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
anyhow = "1.0"
async-stream = "0.3"
async-trait = "0.1"
bindle = { version = "0.3", default-features = false, features = ["client", "server", "caching"] }
bindle = { version = "0.8.0", default-features = false, features = ["client", "server", "caching"] }
cap-std = "^0.22"
clap = "2.33.3"
docker_credential = "1.0.1"
Expand Down
3 changes: 2 additions & 1 deletion examples/mkbindle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ async fn main() -> Result<(), anyhow::Error> {
std::env::var("BINDLE_URL").unwrap_or_else(|_| "http://127.0.0.1:8080/v1".to_owned());

// Connect to our Bindle server
let bindler = bindle::client::Client::new(bindle_server.as_str())?;
let token = bindle::client::tokens::NoToken::default();
let bindler = bindle::client::Client::new(bindle_server.as_str(), token)?;

// Create the invoice
let iid = inv.bindle.id.clone();
Expand Down
9 changes: 9 additions & 0 deletions src/bindle_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ mod test {
let inv = InvoiceUnderstander::new(&Invoice {
bindle_version: "v1".to_owned(),
yanked: None,
yanked_signature: None,
signature: None,
annotations: None,
bindle: BindleSpec {
Expand All @@ -247,6 +248,7 @@ mod test {
size: 1234,
annotations: None,
feature: None,
origin: None,
},
conditions: Some(Condition {
member_of: Some(vec!["coffee".to_owned()]),
Expand All @@ -261,6 +263,7 @@ mod test {
size: 1234,
annotations: None,
feature: None,
origin: None,
},
conditions: Some(Condition {
member_of: Some(vec!["coffee".to_owned()]),
Expand All @@ -275,6 +278,7 @@ mod test {
size: 1234,
annotations: None,
feature: None,
origin: None,
},
conditions: Some(Condition {
member_of: None,
Expand Down Expand Up @@ -302,6 +306,7 @@ mod test {
size: 1234,
annotations: None,
feature: None,
origin: None,
},
conditions: Some(Condition {
member_of: None,
Expand All @@ -323,6 +328,7 @@ mod test {
let inv = Invoice {
bindle_version: "v1".to_owned(),
yanked: None,
yanked_signature: None,
signature: None,
annotations: None,
bindle: BindleSpec {
Expand All @@ -347,6 +353,7 @@ mod test {
size: 1234,
annotations: None,
feature: None,
origin: None,
},
conditions: Some(Condition {
member_of: Some(vec!["coffee".to_owned()]),
Expand All @@ -361,6 +368,7 @@ mod test {
size: 1234,
annotations: None,
feature: None,
origin: None,
},
conditions: Some(Condition {
member_of: Some(vec!["coffee".to_owned()]),
Expand All @@ -375,6 +383,7 @@ mod test {
size: 1234,
annotations: None,
feature: None,
origin: None,
},
conditions: Some(Condition {
member_of: None,
Expand Down
13 changes: 7 additions & 6 deletions src/emplacer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ impl Emplacer {
}

async fn emplace_remote_bindle(self, bindle_base_url: &Url, id: &bindle::Id) -> anyhow::Result<PreHandlerConfiguration> {
let client = bindle::client::Client::new(bindle_base_url.as_str())?;
let token = bindle::client::tokens::NoToken::default();
let client = bindle::client::Client::new(bindle_base_url.as_str(), token)?;

self.emplace_bindle(&client, id).await
}
Expand Down Expand Up @@ -207,7 +208,7 @@ trait BindleReader {
}

#[async_trait::async_trait]
impl BindleReader for bindle::client::Client {
impl<T: bindle::client::tokens::TokenManager + Send + Sync> BindleReader for bindle::client::Client<T> {
async fn get_invoice_bytes(&self, id: &bindle::Id) -> anyhow::Result<Vec<u8>> {
let invoice = self.get_invoice(id).await
.with_context(|| format!("Error fetching remote invoice {}", &id))?;
Expand Down Expand Up @@ -257,7 +258,7 @@ mod test {

#[tokio::test]
async fn can_emplace_standalone_bindle() {
let test_id = bindle::Id::from_str("itowlson/toast-on-demand/0.1.0-ivan-2021.09.24.17.06.16.069")
let test_id = bindle::Id::from_str("itowlson/toast-on-demand/0.1.0-ivan-20210924170616069")
.expect("Test bindle ID should have been valid");
let asset_cache_dir = pick_test_dir();
let handlers = HandlerConfigurationSource::StandaloneBindle(test_data_dir(), test_id);
Expand All @@ -273,13 +274,13 @@ mod test {
"Expected module parcel in asset directory but not found");

// There should be an asset directory with the SHA of the invoice ID
assert!(asset_cache_dir.join("_ASSETS/5c168e0e969ec344be4044dccd4f68e26f20976a5edac0d49e0c28c57ba465b5").is_dir(),
assert!(asset_cache_dir.join("_ASSETS/28e62d239a12d50b11db734eb4a37bf9e746fd487f2a375d17db3a82d6869d54").is_dir(),
"Expected invoice asset dir in asset directory but not found");

// There should be assets in the asset directory
assert!(asset_cache_dir.join("_ASSETS/5c168e0e969ec344be4044dccd4f68e26f20976a5edac0d49e0c28c57ba465b5/images/raw-toast.jpeg").is_file(),
assert!(asset_cache_dir.join("_ASSETS/28e62d239a12d50b11db734eb4a37bf9e746fd487f2a375d17db3a82d6869d54/images/raw-toast.jpeg").is_file(),
"Expected image file in invoice asset directory but not found");
assert!(asset_cache_dir.join("_ASSETS/5c168e0e969ec344be4044dccd4f68e26f20976a5edac0d49e0c28c57ba465b5/images/derrida.png").is_file(),
assert!(asset_cache_dir.join("_ASSETS/28e62d239a12d50b11db734eb4a37bf9e746fd487f2a375d17db3a82d6869d54/images/derrida.png").is_file(),
"Where in the world in Jacques Derrida?");

tokio::fs::remove_dir_all(&asset_cache_dir).await
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ mod test {
const DYNAMIC_ROUTES_SA_ID: &str = "dynamic-routes/0.1.0";
const HTTP_TEST_ID: &str = "http-test/0.1.0";
const PRINT_ENV_SA_ID: &str = "print-env/0.1.0";
const TOAST_ON_DEMAND_SA_ID: &str = "itowlson/toast-on-demand/0.1.0-ivan-2021.09.24.17.06.16.069";
const TOAST_ON_DEMAND_SA_ID: &str = "itowlson/toast-on-demand/0.1.0-ivan-20210924170616069";
const TEST1_MODULE_MAP_FILE: &str = "test1.toml";
#[cfg(target_os = "windows")]
const TEST2_MODULE_MAP_FILE: &str = "test2.toml";
Expand Down
4 changes: 2 additions & 2 deletions src/module_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ async fn load_bindle(
%bindle_name,
"Loading bindle",
);

let bindler = bindle::client::Client::new(server)?;
let token = bindle::client::tokens::NoToken::default();
let bindler = bindle::client::Client::new(server, token)?;
let invoice = bindler.get_invoice(bindle_name).await?;

// TODO: We need to load a keyring and then get it all the way here.
Expand Down
2 changes: 1 addition & 1 deletion testdata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### `standalone-bindles` directory

* 5c168...: ID `itowlson/toast-on-demand/0.1.0-ivan-2021.09.24.17.06.16.069`
* 28e62...: ID `itowlson/toast-on-demand/0.1.0-ivan-20210924170616069`
- WASM module that returns a HTML page with static text, two `img` tags and a list of EVs
- WASM module for `wagi-fileserver`
- Two image parcels for testing assets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ bindleVersion = '1.0.0'

[bindle]
name = 'itowlson/toast-on-demand'
version = '0.1.0-ivan-2021.09.24.17.06.16.069'
version = '0.1.0-ivan-20210924170616069'
authors = ['itowlson']

[[parcel]]
Expand Down

0 comments on commit 4d261cf

Please sign in to comment.