project-stacker / stacker

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

add stacker version as annotation to images #602

Closed mikemccracken closed 8 months ago

mikemccracken commented 8 months ago

It can be useful to know which version of stacker created an image. Let's put it in there.

Moves some things around to avoid multiple definitions & import loops.

hallyn commented 8 months ago

Looks good to me, but would also like to see the oci annotation.

mikemccracken commented 8 months ago

here's an example of a manifest with the annotation we get from this change:

{
  "schemaVersion": 2,
  "mediaType": "application/vnd.oci.image.manifest.v1+json",
  "config": {
    "mediaType": "application/vnd.oci.image.config.v1+json",
    "digest": "sha256:8234d3f66d0841bdaf46c406fa657ff0c8656a140cc9644169f6437268668ff1",
    "size": 709
  },
  "layers": [
    {
      "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
      "digest": "sha256:6d7944e47a2816085f3558cbd8f8b1c9ab7ea946908701dc86e824d41316daf4",
      "size": 1916744
    },
    {
      "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
      "digest": "sha256:8f8602a5f876184701dc7aff30b2401f8cd6b1cf80153ec560c9b6b1927041aa",
      "size": 209
    }
  ],
  "annotations": {
    "io.stackeroci.stacker.stacker_version": "v1.0.0-rc12-3-gef4e4be-dirty",
    "io.stackeroci.stacker.stacker_yaml": "\nminbasebase:\n  build_only: true\n  from:\n    type: tar\n    url: minrfs-w-resolvconf-and-dirs.tgz\n\nminbase:\n  from:\n    type: built\n    tag: minbasebase\n  run: |\n    echo \"foo\" > \"/usr/local/bin/foo\"\n    echo \"$(</etc/resolv.conf)\"\n    echo done.\n"
  }
}
codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 57.46%. Comparing base (b585bfb) to head (b9452c3). Report is 1 commits behind head on main.

:exclamation: Current head b9452c3 differs from pull request most recent head 5303764. Consider uploading reports for the commit 5303764 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #602 +/- ## ========================================== + Coverage 57.38% 57.46% +0.07% ========================================== Files 64 65 +1 Lines 7566 7709 +143 ========================================== + Hits 4342 4430 +88 - Misses 2481 2522 +41 - Partials 743 757 +14 ```

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

mikemccracken commented 8 months ago

+1 -- maybe a quick pkg/lib/version_test.go to make codecov happy?

I'm not too familiar with codecov, having a hard time making sense of its view. I don't think it's referring to pkg/lib/version.go - it claims the lines added in api.go don't have tests associated, but there are no unit tests for anything in there (and there shouldn't be, it is just wrappers around Sprintf)... I assume it's getting coverage from the integration bats tests too, but when I look in codecov to see how the other funcs in api.go are being covered, it now says all the lines in that file are covered - in this view of the PR on codecov https://app.codecov.io/gh/project-stacker/stacker/pull/602 it says the PR's changes have 100% coverage. Not sure how to satisfy it

raharper commented 8 months ago

+1 -- maybe a quick pkg/lib/version_test.go to make codecov happy?

I'm not too familiar with codecov, having a hard time making sense of its view.

I'm not quite sure either, but most files in pkg/lib/ have_test.go` files -- could write one and see if that' makes it happy?