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

Reference images by digest in docker driver #166

Closed
wants to merge 1 commit into from

Conversation

jlegrone
Copy link
Member

This builds on the work in #114 by supporting the same functionality for the docker driver.

Signed-off-by: Jacob LeGrone <git@jacob.work>
@jlegrone jlegrone force-pushed the jlegrone/docker-ref-by-digest branch from 92fe083 to 30a9f1b Compare December 13, 2019 20:56
},
},
"digest only": {
expected: "foo@sha256:7ea254518",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to use a full SHA 256 hash to avoid any confusion. Maybe just pad it with zeros?

Copy link
Contributor

@glyn glyn left a comment

Choose a reason for hiding this comment

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

Approved with a small suggestion.

// If no digest is available, only the image will be returned and the boolean value will be false.
func (i *BaseImage) DigestedRef() (string, bool) {
if i.Digest == "" {
return i.Image, false
Copy link
Contributor

Choose a reason for hiding this comment

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

I think returning false here is not accurate, as i.Image can be a digested reference itself. We should test if the image name is a digested reference here and return the result.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm on the fence about this. The spec states that

If the contentDigest is not present, the runtime SHOULD report an error so the user is aware that there is no contentDigest provided.

If an image contains what we interpret to be a digest, then some runtimes could certainly opt to use this in lieu of an explicit contentDigest. But having the boolean correspond to whether contentDigest has actually been set seems most in line with the spec as written.

Image: "foo:bar",
},
},
"digest only": {
Copy link
Contributor

Choose a reason for hiding this comment

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

We're missing a case here:

"digested reference": {
    expected: "foo@sha256:7ea254518cab82f53938523eab0dc6601a3dd1edf700f1f6235e66e27cbc7986
    hasDigest: true,
    image: BaseImage{
        Image: "foo@sha256:7ea254518cab82f53938523eab0dc6601a3dd1edf700f1f6235e66e27cbc7986",
    },
},

@silvin-lubecki
Copy link
Contributor

Regarding @glyn comment on this isssue #145 (comment) I don't think we should use the contentDigest field as it is proposed in this PR.

Regardless of which definition we choose, it seems clear that we can't simply append the contentDigest to the end of the image field to create a digested image reference because the image field may already be digested.

@glyn WDYT?

@glyn
Copy link
Contributor

glyn commented Dec 16, 2019

Regarding @glyn comment on this isssue #145 (comment) I don't think we should use the contentDigest field as it is proposed in this PR.

Regardless of which definition we choose, it seems clear that we can't simply append the contentDigest to the end of the image field to create a digested image reference because the image field may already be digested.

@glyn WDYT?

Of course, I agree with my own comment. But are you saying that the current PR proposes a particular interpretation of contentDigest?

@silvin-lubecki
Copy link
Contributor

Of course, I agree with my own comment. But are you saying that the current PR proposes a particular interpretation of contentDigest?

Yes I think here https://github.com/cnabio/cnab-go/pull/166/files#diff-187c9d266554ba3ff27d602db2a12221R105

return fmt.Sprintf("%s@%s", i.Image, i.Digest), true

i.Digest is the contentDigest (this field is unfortunately badly named). I guess it is exactly what your are referring to in your previous comment we can't simply append the contentDigest to the end of the image field to create a digested image reference. Or am I totally wrong? 🤔

@glyn
Copy link
Contributor

glyn commented Dec 16, 2019

That's correct, but even if the image field is not digested, it only makes sense to add the contentDigest on the end if contentDigest is a repo digest (and not an image id). We won't know for sure which it is until cnabio/cnab-spec#287 has been decided.

@radu-matei
Copy link
Member

/brig run

@silvin-lubecki
Copy link
Contributor

Agreed, that's why I think we should put that PR on hold.

@vdice
Copy link
Member

vdice commented Aug 20, 2020

Attempt to clarify the spec (address cnabio/cnab-spec#287) has been issued in cnabio/cnab-spec#384.

Meanwhile, this PR looks great to me. It looks like there are some unit test suggestions remaining and a rebase is needed. These changes will come in handy for digest validation in #227.

@vdice
Copy link
Member

vdice commented Sep 17, 2020

cnabio/cnab-spec#384 has been merged.

@jlegrone any chance this branch can be rebased when convenient?

Base automatically changed from master to main February 5, 2021 15:02
@carolynvs
Copy link
Contributor

@jlegrone I'm closing this PR since it's been 2 years and has drifted. It sounds like from #269 that DataDog may not need this change anymore? If you want to resubmit this PR, rebased on the latest release, I'm happy to help get that pushed through.

@carolynvs carolynvs closed this Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants