-
Notifications
You must be signed in to change notification settings - Fork 39
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
Conversation
Signed-off-by: Jacob LeGrone <git@jacob.work>
92fe083
to
30a9f1b
Compare
}, | ||
}, | ||
"digest only": { | ||
expected: "foo@sha256:7ea254518", |
There was a problem hiding this comment.
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?
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 nocontentDigest
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": { |
There was a problem hiding this comment.
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",
},
},
Regarding @glyn comment on this isssue #145 (comment) I don't think we should use the
@glyn WDYT? |
Of course, I agree with my own comment. But are you saying that the current PR proposes a particular interpretation of |
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
|
That's correct, but even if the image field is not digested, it only makes sense to add the |
/brig run |
Agreed, that's why I think we should put that PR on hold. |
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. |
cnabio/cnab-spec#384 has been merged. @jlegrone any chance this branch can be rebased when convenient? |
This builds on the work in #114 by supporting the same functionality for the docker driver.