Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stacked] Add docs to inventory code #864

Merged

Conversation

schneems
Copy link
Contributor

@schneems schneems commented Oct 1, 2024

No description provided.

@schneems schneems requested a review from a team as a code owner October 1, 2024 18:38
Copy link
Member

@joshwlewis joshwlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me. What do you think about merging this to your PR @runesoerensen.

libherokubuildpack/src/inventory.rs Outdated Show resolved Hide resolved
libherokubuildpack/src/inventory.rs Outdated Show resolved Hide resolved
libherokubuildpack/src/inventory.rs Outdated Show resolved Hide resolved
libherokubuildpack/src/inventory.rs Outdated Show resolved Hide resolved
libherokubuildpack/src/inventory/artifact.rs Outdated Show resolved Hide resolved
libherokubuildpack/src/inventory/artifact.rs Show resolved Hide resolved
@runesoerensen
Copy link
Contributor

Makes sense to merge the changes into the other branch! I've added a few comments, but this branch should also be updated to use the new feature flags (and replace the TODO in the comments).

@schneems schneems force-pushed the schneems/doc-migrate-inventory-code branch from ebac8c0 to a981572 Compare October 2, 2024 21:52
@schneems
Copy link
Contributor Author

schneems commented Oct 2, 2024

Updated with the latest features. Leaving the merge up to you.

@runesoerensen
Copy link
Contributor

I've updated the example usage docs in inventory.rs to show full end-to-end usage that works (and runs during CI) 28204a0 - feel free to adjust!

@schneems
Copy link
Contributor Author

schneems commented Oct 3, 2024

@runesoerensen thanks. I like that the example also now gives a sample of what the resulting inventory.toml format will look like.

I added a line that shows how to hex::encode the value for printing/display. I would ideally like someone to also see the file interactions i.e. download_file right in this example, but couldn't figure out a way to make it work and run. I would also like to show generating a sha from disk, but it's not that hard to infer that if we can get it from a string we can std::fs::read_to_string.

Given all of that, I think what we've got is pretty great. Take a look at my commit and either merge or comment.

@runesoerensen runesoerensen merged commit 1ac0955 into migrate-inventory-code Oct 3, 2024
4 checks passed
@runesoerensen runesoerensen deleted the schneems/doc-migrate-inventory-code branch October 3, 2024 21:43
runesoerensen added a commit that referenced this pull request Oct 16, 2024
* Add src files from inventory repo

Copy all files currently living in https://github.com/Malax/inventory/tree/main/inventory/src without any changes.

Co-Authored-By: Manuel Fuchs <[email protected]>
Co-Authored-By: Josh W Lewis <[email protected]>

* Merge lib.rs and inventory.rs

* Declare inventory module and feature

* Prefer PhantomData

* Add must_use attribute

* Remove unused import

* Allow unwrap for now

* Add sha2 feature

We may want to consider another approach here (e.g. naming the feature `inventory-sha2` and/or pulling in the inventory dependency ["inventory", "dep:sha2"]).

While the crate will be pulled in if a user enables the `sha2`, the inventory-specific sha2 code won't be compiled unless the `inventory` feature is also enabled.

* Add semver feature

* Include patch version in dependency requirements

* Add inventory toml dependency

* Add inventory thiserror dependency

* Add changelog entry

* Allow unreachable pub for re-exports

Also see Malax/inventory#2 (comment)

* Remove semver and sha2 re-exports

These re-exports appear to be unnecessary, and doesn't have any impact on code that rely on the `inventory` module (and have the `semver` and/or `sha2` features enabled). Also see related prior discussion here Malax/inventory#2 (comment).

The `semver` and `sha2` modules only contain implementations of public traits, so I don't think we need to re-export those (unlike bringing for instance a function or struct in to scope).

If I understand how trait implementations work correctly, it doesn't matter where an implementation lives (only the visibility of the trait and the type it's implemented for is relevant) - in other words, the implementation will be available to any code that can access both the trait and the type, even across crate binaries.

* Rename `semver` feature to `inventory-semver`

* Rename `sha2` feature to `inventory-sha2`

* [stacked] Add docs to inventory code (#864)

* Add module docs and example

* Document resolve and partial_resolve

* Document more inventory methods

* Document Artifact

* Document ArtifactRequirement

I also suggest we change the name of `inventory/version` to `inventory/artifact_requirement.rs` or `requirement.rs`.

* Update example to compare Checksum instead of string

* Apply suggestions from code review

Co-authored-by: Rune Soerensen <[email protected]>

* Update feature names

* Rewrite example usage

* Show how to display checksum in example

---------

Co-authored-by: Rune Soerensen <[email protected]>

* Group inventory features alphabetically

---------

Co-authored-by: Manuel Fuchs <[email protected]>
Co-authored-by: Josh W Lewis <[email protected]>
Co-authored-by: Richard Schneeman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants