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

Add metadata in imgpkg lock file #132

Merged
merged 12 commits into from
Sep 21, 2021
Merged

Add metadata in imgpkg lock file #132

merged 12 commits into from
Sep 21, 2021

Conversation

cari-lynn
Copy link
Contributor

@cari-lynn cari-lynn commented Jul 22, 2021

When using the --imgpkg-lock-output flag, this PR adds the kbld.carvel.dev/metas annotation.

images:
- annotations:
    kbld.carvel.dev/metas: |
      - Tag: x.x.x
        Type: resolved
        URL: image-name:x.x.x

When using a lock file as input to kbld, this PR also will preserve any kbld.carvel.dev/metas. It will append new metas to the list in the output and an imgpkg Lock file. This results in a history for example:

images:
- annotations:
    kbld.carvel.dev/metas: |
      - Tag: x.x.x
        Type: resolved
        URL: image-name:x.x.x
      - Type: preresolved
        URL: index.docker.io/library/..@sha256:...

Other new behavior:

  • If a kbld.carvel.dev/metas annotation is malformatted, kbld will error.
  • the kbld.carvel.dev/metas annotation must be in the format of several predefined objects, other unknown meta objects will be ignored.

@gcheadle-vmware
Copy link
Contributor

@cari-lynn Requesting review, was unable to select you as a GH reviewer.

pkg/kbld/config/config.go Outdated Show resolved Hide resolved
pkg/kbld/image/preresolved.go Outdated Show resolved Hide resolved
pkg/kbld/cmd/resolve.go Outdated Show resolved Hide resolved
pkg/kbld/config/config.go Outdated Show resolved Hide resolved
pkg/kbld/config/config.go Outdated Show resolved Hide resolved
pkg/kbld/image/preresolved.go Outdated Show resolved Hide resolved
test/e2e/lock_output_test.go Show resolved Hide resolved
@cari-lynn cari-lynn changed the title Add tag metadata in imgpkg lock file Add metadata in imgpkg lock file Sep 8, 2021
@cari-lynn cari-lynn marked this pull request as ready for review September 8, 2021 19:24
@gcheadle-vmware
Copy link
Contributor

This looks good to me. Great idea extracting out the meta interface into its own package, it really cleaned up nicely :)

Copy link
Contributor

@pivotaljohn pivotaljohn left a comment

Choose a reason for hiding this comment

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

This work is really close.

The overall approach looks really good to me.

Details in the comments, below.

pkg/kbld/cmd/resolve.go Outdated Show resolved Hide resolved
pkg/kbld/image/resolved.go Show resolved Hide resolved
pkg/kbld/image/tag_selected.go Show resolved Hide resolved
pkg/kbld/image/tagged.go Show resolved Hide resolved
pkg/kbld/config/image_meta.go Outdated Show resolved Hide resolved
pkg/kbld/config/image_meta.go Outdated Show resolved Hide resolved
@pivotaljohn
Copy link
Contributor

Reviewed w/ @garrettcheadle (offering to make changes if desired):

i think that all suggestions but the last comment are simple changes that I see as improvements. ... If you could make those changes/renames, that would move this along.

👍🏻

In the case of "deliberately ignoring unmarshallable data" ... we have another custom unmarshaller in kbld, maybe we should check if that unmarshaller has an error case for wisdom?

I'll look into that.

@pivotaljohn
Copy link
Contributor

In terms of prior art, I'm seeing this idiom which attempts to unmarshal data into a set of potential structs...

https://github.com/vmware-tanzu/carvel-kbld/blob/f919f7f78a/pkg/kbld/resources/path.go#L78-L91

By the end of the switch, if no suitable struct was found, that was reported as an error.

I think we should do a similar thing in the case of detecting which kind of Meta (if you can successfully unmarshall it, must be that kind!)... but also either emit a warning or error out when it's unrecognized.

Copy link
Contributor

@cppforlife cppforlife left a comment

Choose a reason for hiding this comment

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

(looks like i had review that wasnt submitted. might be a bit stale.)

pkg/kbld/image/preresolved.go Outdated Show resolved Hide resolved
pkg/kbld/image/preresolved.go Outdated Show resolved Hide resolved
pkg/kbld/config/image_meta.go Show resolved Hide resolved
pkg/kbld/config/image_meta.go Outdated Show resolved Hide resolved
pkg/kbld/config/image_meta.go Outdated Show resolved Hide resolved
pkg/kbld/config/image_meta.go Outdated Show resolved Hide resolved
pkg/kbld/config/config.go Outdated Show resolved Hide resolved
pkg/kbld/config/config.go Outdated Show resolved Hide resolved
pkg/kbld/cmd/resolve.go Outdated Show resolved Hide resolved
pkg/kbld/cmd/resolve.go Outdated Show resolved Hide resolved
@pivotaljohn
Copy link
Contributor

pivotaljohn commented Sep 20, 2021

Reviewed w/ @cppforlife over the phone.

  • UniqueImageOverrides is not needed when preparing to output imgpkg-flavored lock files. The other callers are in deprecated code. We'll remove this invocation from "resolve"
  • to minimize the impact of this change on working ocde, we'll fix the compilation error, by writing a custom Equals() that ignores metas in the comparison. 👍🏻

@pivotaljohn pivotaljohn temporarily deployed to DockerHub E2E September 20, 2021 22:34 Inactive
cari-lynn and others added 8 commits September 20, 2021 15:41
- exclude metas in imgpkg lock when image is given in digest form
Signed-off-by: Cari Dean <[email protected]>
- return err from unmarshalling image lock
- Use custom unmarshaler for image metas
- Move Metas from image package to config package
- Rename Metas to ImageMetas
cari-lynn and others added 3 commits September 20, 2021 15:41
- extract meta type names as constants
- fix slice append gotcha: when creating a new slice, copy from old
  first (i.e. copyAndAppendMeta())
- various renames and inlining to improve clarity
- meta are descriptive, not identifying, so they have no bearing on
  whether two ImageOverrides are equal.

Given that all overrides are created brand fresh during a resolve for
the kbld lock file, there's no need to dedup them (removed call to
UniqueImageOverride()).
@pivotaljohn pivotaljohn temporarily deployed to DockerHub E2E September 20, 2021 23:00 Inactive
@cppforlife cppforlife merged commit 517a578 into develop Sep 21, 2021
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.

6 participants