Skip to content

Commit

Permalink
Update Ruby Install Layer to Struct API and bullet stream output (#325)
Browse files Browse the repository at this point in the history
* Print all changes on cache change

The `Changed` struct limits us to a single reason for a change. By using a vec we can list all changes. There will be some redundancy in the output if multiple layers are keyed to the same values (such as distro name or distro version). That might be okay, or we could try storing common information in its own layer up front, and printing that information once (the specific values) and then later we could say "distro version changed" rather than "distro verision changed (22.04 to 24.04)".

* Format cache changed values

* Rename RubyInstallLayerMetadata to Metadata

* Replace Ruby layer trait with layer struct API

* Update RubyInstallLayer signature to accept and return bullet stream

Changing the logging will be it's own commit.

* Switch Ruby Install build output to bullet stream

* Reduce repetition in change output

* Remove redundant logic

The explicit check if the old and new metadata structs were equal isn't needed since I'm already comparing each individual element and have logic to return `None` if they're the same.

* Use Vec instead of Option<Vec>

Discussion #325 (comment). Some([]) (empty vec) is a possible state from the type signature `Option<Vec<String>>` the state of Some/None is ambiguous without more information from the function. This code is easier to accidentally use the wrong logic in the consumer, but the correct implementation checks the direct properties we desire instead of relying on internal implementation of a function.

We could alternatively introduce a non-empty vector, there are several crates that provide this, but it's more overhead that needed here.
  • Loading branch information
schneems authored Sep 24, 2024
1 parent 6f9ec54 commit d8a1d0a
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 190 deletions.
Loading

0 comments on commit d8a1d0a

Please sign in to comment.