-
Notifications
You must be signed in to change notification settings - Fork 41
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
sparse: do not modify media type when unspecified #233
Conversation
The media type should only be modified when the user specifies it. In my case I noticed the digest given by the sparse.Image was not the same as the image it was dervied from. This was because the logic to set the media type defaulted to overriding to OCI if the media type was not specified. This commit changes the logic to only override the media type if the user specifies it. Signed-off-by: Jesse Brown <[email protected]>
Signed-off-by: Jesse Brown <[email protected]>
layout/new.go
Outdated
@@ -58,7 +59,7 @@ func NewImage(path string, ops ...ImageOption) (*Image, error) { | |||
ri.createdAt = imageOpts.createdAt | |||
} | |||
|
|||
if imageOpts.mediaTypes == imgutil.MissingTypes { | |||
if imageOpts.mediaTypes == imgutil.MissingTypes && !hasBaseImage { |
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.
Yeah. The idea is that if layout.WithMediaTypes
is omitted, the imageOpts.mediaTypes
will be imgutil.MissingTypes
. In the case where there was a base image (always true in sparse, not always true in layout) - we should default to matching the base image.
Signed-off-by: Jesse Brown <[email protected]>
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.
Great job @jabrown85! This looks good to me!
Signed-off-by: Jesse Brown <[email protected]>
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.
Are we going to need to change the lifecycle at all? Or should that be covered by "has base image"?
I don't think lifecycle is aware of sparse vs layout at all today and this should change nothing there. |
As I mentioned on Slack:
-f, --format string MANIFEST TYPE (oci, v2s1, or v2s2) to use in the destination (default is manifest type of source, with fallbacks)
|
The media type should only be modified when the user specifies it. In my case I noticed the digest given by the sparse.Image was not the same as the image it was dervied from. This was because the logic to set the media type defaulted to overriding to OCI if the media type was not specified. This commit changes the logic to only override the media type if the user specifies it.