Skip to content

Commit

Permalink
Clarify directionality of layer stacks
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Bottriell <rbottriell@ilm.com>
  • Loading branch information
rydrman committed Nov 20, 2023
1 parent d74e956 commit 6c46cfb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
20 changes: 8 additions & 12 deletions crates/spfs-cli/main/src/cmd_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ impl CmdInfo {
"refs:".bright_blue(),
self.format_digest(obj.digest()?, repo).await?
);
println!("{}", "stack:".bright_blue());
for reference in obj.stack {
println!(" - {}", self.format_digest(reference, repo).await?);
println!("{}", "stack (top-down):".bright_blue());
for reference in obj.stack.iter().rev() {
println!(" - {}", self.format_digest(*reference, repo).await?);
}
}

Expand Down Expand Up @@ -187,15 +187,11 @@ impl CmdInfo {
async fn print_global_info(&self, repo: &spfs::storage::RepositoryHandle) -> Result<()> {
let runtime = spfs::active_runtime().await?;

println!("{}", "Active Runtime:".green());
println!(" {}: {}", "id:".bright_blue(), runtime.name());
println!(
" {}: {}",
"editable:".bright_blue(),
runtime.status.editable
);
println!("{}", "stack".bright_blue());
for digest in runtime.status.stack.iter() {
println!("{}:", "Active Runtime".green());
println!(" {}: {}", "id".bright_blue(), runtime.name());
println!(" {}: {}", "editable".bright_blue(), runtime.status.editable);
println!("{}:", "stack (top-down)".bright_blue());
for digest in runtime.status.stack.iter().rev() {
print!(" - {}, ", self.format_digest(*digest, repo).await?);
let object = repo.read_ref(digest.to_string().as_str()).await?;
println!(
Expand Down
1 change: 1 addition & 0 deletions crates/spfs/src/graph/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ mod platform_test;
/// future runtimes.
#[derive(Debug, Eq, PartialEq, Default, Clone)]
pub struct Platform {
/// Items in the platform, with the top-most/override entry being last
pub stack: Vec<encoding::Digest>,
}

Expand Down
3 changes: 2 additions & 1 deletion crates/spfs/src/runtime/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl Default for Author {
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq)]
pub struct Status {
/// The set of layers that are being used in this runtime
/// with the top-most/override layer being last
pub stack: Vec<encoding::Digest>,
/// Additional layers that were created automatically due to the stack
/// being too large.
Expand Down Expand Up @@ -874,7 +875,6 @@ impl Runtime {
/// update any currently running environment.
pub fn push_digest(&mut self, digest: encoding::Digest) {
let mut new_stack = Vec::with_capacity(self.status.stack.len() + 1);
new_stack.push(digest);
for existing in self.status.stack.drain(..) {
// we do not want the same layer showing up twice, one for
// efficiency and two it causes errors in overlayfs so promote
Expand All @@ -884,6 +884,7 @@ impl Runtime {
}
new_stack.push(existing);
}
new_stack.push(digest);
self.status.stack = new_stack;
}

Expand Down

0 comments on commit 6c46cfb

Please sign in to comment.