-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
253 additions
and
49 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "circe" | ||
version = "0.2.0" | ||
version = "0.3.0" | ||
edition = "2021" | ||
authors = ["Jessica Black <[email protected]>", "FOSSA Inc. <[email protected]>"] | ||
description = "Extracts and examines the contents of containers" | ||
|
@@ -24,3 +24,4 @@ tracing-tree = { version = "0.4.0" } | |
circe_lib = { path = "../lib" } | ||
serde_json = "1.0.133" | ||
derive_more = { version = "1.0.0", features = ["debug"] } | ||
pluralizer = "0.4.0" |
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,54 @@ | ||
use circe_lib::{registry::Registry, Authentication}; | ||
use clap::Parser; | ||
use color_eyre::eyre::{Context, Result}; | ||
use derive_more::Debug; | ||
use pluralizer::pluralize; | ||
use std::collections::HashMap; | ||
use tracing::{debug, info}; | ||
|
||
use crate::extract::Target; | ||
|
||
#[derive(Debug, Parser)] | ||
pub struct Options { | ||
/// Target to list | ||
#[clap(flatten)] | ||
target: Target, | ||
} | ||
|
||
#[tracing::instrument] | ||
pub async fn main(opts: Options) -> Result<()> { | ||
info!("extracting image"); | ||
|
||
let auth = match (opts.target.username, opts.target.password) { | ||
(Some(username), Some(password)) => Authentication::basic(username, password), | ||
_ => Authentication::default(), | ||
}; | ||
let registry = Registry::builder() | ||
.maybe_platform(opts.target.platform) | ||
.reference(opts.target.image) | ||
.auth(auth) | ||
.build() | ||
.await | ||
.context("configure remote registry")?; | ||
|
||
let layers = registry.layers().await.context("list layers")?; | ||
let count = layers.len(); | ||
info!("enumerated {}", pluralize("layer", count as isize, true)); | ||
|
||
let mut listing = HashMap::new(); | ||
for (descriptor, layer) in layers.into_iter().zip(1usize..) { | ||
info!(layer = %descriptor, %layer, "reading layer"); | ||
let files = registry | ||
.list_files(&descriptor) | ||
.await | ||
.context("list files")?; | ||
|
||
debug!(layer = %descriptor, files = %files.len(), "listed files"); | ||
listing.insert(descriptor.digest.to_string(), files); | ||
} | ||
|
||
let rendered = serde_json::to_string_pretty(&listing).context("render listing")?; | ||
println!("{rendered}"); | ||
|
||
Ok(()) | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "circe_lib" | ||
version = "0.2.0" | ||
version = "0.3.0" | ||
edition = "2021" | ||
authors = ["Jessica Black <[email protected]>", "FOSSA Inc. <[email protected]>"] | ||
description = "Extracts and examines the contents of containers" | ||
|
Oops, something went wrong.