Skip to content

[stacked] Add docs to inventory code#864

Merged
runesoerensen merged 10 commits into
migrate-inventory-codefrom
schneems/doc-migrate-inventory-code
Oct 3, 2024
Merged

[stacked] Add docs to inventory code#864
runesoerensen merged 10 commits into
migrate-inventory-codefrom
schneems/doc-migrate-inventory-code

Conversation

@schneems

@schneems schneems commented Oct 1, 2024

Copy link
Copy Markdown
Contributor

No description provided.

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

@joshwlewis joshwlewis left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread libherokubuildpack/src/inventory.rs Outdated
Comment thread libherokubuildpack/src/inventory.rs Outdated
Comment thread libherokubuildpack/src/inventory.rs Outdated
Comment thread libherokubuildpack/src/inventory.rs Outdated
Comment thread libherokubuildpack/src/inventory/artifact.rs Outdated
Comment thread libherokubuildpack/src/inventory/artifact.rs
@runesoerensen

Copy link
Copy Markdown
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

schneems commented Oct 2, 2024

Copy link
Copy Markdown
Contributor Author

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

Comment thread libherokubuildpack/src/inventory.rs Outdated
@runesoerensen

Copy link
Copy Markdown
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

schneems commented Oct 3, 2024

Copy link
Copy Markdown
Contributor Author

@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
@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 <manuel.fuchs@salesforce.com>
Co-Authored-By: Josh W Lewis <josh.lewis@salesforce.com>

* 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 <rsoerensen@salesforce.com>

* Update feature names

* Rewrite example usage

* Show how to display checksum in example

---------

Co-authored-by: Rune Soerensen <rsoerensen@salesforce.com>

* Group inventory features alphabetically

---------

Co-authored-by: Manuel Fuchs <manuel.fuchs@salesforce.com>
Co-authored-by: Josh W Lewis <josh.lewis@salesforce.com>
Co-authored-by: Richard Schneeman <richard.schneeman+no-recruiters@gmail.com>
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