project-stacker / stacker

Build OCI images natively from a declarative format
https://stackerbuild.io
Apache License 2.0
208 stars 34 forks source link

feat: print hashes for imports in yaml format #608

Closed mikemccracken closed 6 months ago

mikemccracken commented 7 months ago

For import types that will be checked, save the calculated hash of the downloaded file and print them together in the format of a yaml imports section for easy copy and pasting to add hashes to a file.

Because we only the parse file contents after the substitution placeholders are replaced, this isn't a direct copy and paste replacement, but it is an improvement, and it should be easy enough to tell which expanded paths come from what input.

The relevant info is already present if you build with --debug, but this consolidates it into one place, and without --debug, the hash is not printed.

Here is an example of the output without --debug:

preparing image minbase...
downloading https://host/path/to/atomix-tools-0.5.10.tgz
27.82 MiB / 27.82 MiB [----------------------------------------------------------------------------------------------------------------------------------------------] 100.00% 183.33 MiB p/s
imported file hashes:
  - path: "https://host/path/to/atomix-tools-0.5.10.tgz"
    hash: "f6c3eb0ed978ba63b3b37741fa1ebecc764a4d907a0b18b24c48482218d1a50d"
codecov[bot] commented 7 months ago

Codecov Report

Attention: Patch coverage is 61.53846% with 15 lines in your changes are missing coverage. Please review.

Project coverage is 57.44%. Comparing base (86ba851) to head (eaa2d19).

Files Patch % Lines
pkg/stacker/import.go 58.62% 10 Missing and 2 partials :warning:
pkg/stacker/network.go 66.66% 2 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #608 +/- ## ========================================== + Coverage 57.40% 57.44% +0.04% ========================================== Files 65 65 Lines 7709 7717 +8 ========================================== + Hits 4425 4433 +8 Misses 2527 2527 Partials 757 757 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.