-
Notifications
You must be signed in to change notification settings - Fork 42
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
Layout wraps v1 image #243
Conversation
The details of storing images can be left up to each implementation Signed-off-by: Natalie Arellano <narellano@vmware.com>
a103082
to
5286195
Compare
Signed-off-by: Natalie Arellano <narellano@vmware.com>
5286195
to
c3794cc
Compare
Signed-off-by: Natalie Arellano <narellano@vmware.com>
This will allow us to preserve the digest when no modifying options are provided Signed-off-by: Natalie Arellano <narellano@vmware.com>
… the image struct (image struct can go away) Signed-off-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
@@ -346,9 +333,6 @@ func (i *CNBImageCore) AddLayerWithDiffIDAndHistory(path, _ string, history v1.H | |||
} | |||
|
|||
func (i *CNBImageCore) Rebase(baseTopLayerDiffID string, withNewBase Image) error { | |||
if i.Kind() != withNewBase.Kind() { |
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.
If my underlying image i is a remote image, does it mean I can rebase it with a local or layout image?
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, in theory - I haven't tested it, but probably you can
Signed-off-by: Natalie Arellano <narellano@vmware.com>
I think you are still working in some TODOs but overall it looks good to me! As always, terrific job @natalieparellano! |
…dia types (or other modifications) are requested Signed-off-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #243 +/- ##
==========================================
+ Coverage 58.86% 59.79% +0.93%
==========================================
Files 32 32
Lines 3694 3369 -325
==========================================
- Hits 2174 2014 -160
+ Misses 1160 1044 -116
+ Partials 360 311 -49 |
93f1d0b
to
0153fc0
Compare
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
0153fc0
to
59770c9
Compare
This reverts commit 59770c9.
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
@@ -87,136 +85,16 @@ type Platform struct { | |||
OSVersion string | |||
} | |||
|
|||
type MediaTypes int |
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.
Moved to new.go
} | ||
configFile.History = NormalizedHistory(configFile.History, len(configFile.RootFS.DiffIDs)) | ||
return mutate.ConfigFile(image, configFile) | ||
} | ||
|
||
func NormalizedHistory(history []v1.History, nLayers int) []v1.History { |
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.
Moved to new.go
if len(indexManifest.Manifests) > 1 { | ||
// Find based on platform (os/arch) | ||
for _, m := range indexManifest.Manifests { | ||
if m.Platform.OS == platform.OS && m.Platform.Architecture == platform.OS { |
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.
m.Platform.Architecture == platform.OS
seems unintended
@@ -346,9 +333,6 @@ func (i *CNBImageCore) AddLayerWithDiffIDAndHistory(path, _ string, history v1.H | |||
} | |||
|
|||
func (i *CNBImageCore) Rebase(baseTopLayerDiffID string, withNewBase Image) error { | |||
if i.Kind() != withNewBase.Kind() { |
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, in theory - I haven't tested it, but probably you can
type ImageStore interface { | ||
Contains(identifier string) bool | ||
Delete(identifier string) error | ||
Save(image IdentifiableV1Image, withName string, withAdditionalNames ...string) (string, error) | ||
SaveFile(image IdentifiableV1Image, withName string) (string, error) | ||
|
||
DownloadLayersFor(identifier string) error | ||
Layers() []v1.Layer | ||
} |
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.
Originally I thought this could be an interface that all packages could implement, but since most packages would override the methods that call this interface it's not so useful
|
||
if i.Image, err = imgutil.OverrideHistoryIfNeeded(i.Image); err != nil { | ||
return fmt.Errorf("override history: %w", err) | ||
if err := i.SetCreatedAtAndHistory(); err != nil { |
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 have to do this at the point of save (vs instantiation) because otherwise we might modify the digest when there is a base image and that could be surprising
err = image.Save() | ||
h.AssertNil(t, err) |
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.
Saving could mutate the digest and that is expected
createdAt := NormalizedDateTime | ||
if !options.CreatedAt.IsZero() { | ||
createdAt = options.CreatedAt | ||
} | ||
if err = image.MutateConfigFile(func(c *v1.ConfigFile) { | ||
c.Created = v1.Time{Time: createdAt} | ||
c.Container = "" | ||
}); err != nil { | ||
return nil, err | ||
} | ||
|
||
if !options.PreserveHistory { | ||
if err = image.MutateConfigFile(func(c *v1.ConfigFile) { | ||
for j := range c.History { | ||
c.History[j] = v1.History{Created: v1.Time{Time: createdAt}} | ||
} | ||
}); err != nil { | ||
return nil, err | ||
} | ||
} |
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.
Moved this out of new method to avoid mutating the digest when there is a base image
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.
Worth noting, I tried importing this branch in pack and the lifecycle, and all tests are happy over there :)
No description provided.