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

Layout wraps v1 image #243

Merged
merged 15 commits into from
Feb 5, 2024
Merged

Layout wraps v1 image #243

merged 15 commits into from
Feb 5, 2024

Conversation

natalieparellano
Copy link
Member

No description provided.

The details of storing images can be left up to each implementation

Signed-off-by: Natalie Arellano <narellano@vmware.com>
@natalieparellano natalieparellano force-pushed the layout-wraps-v1 branch 6 times, most recently from a103082 to 5286195 Compare January 29, 2024 23:01
Signed-off-by: Natalie Arellano <narellano@vmware.com>
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() {
Copy link
Member

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?

Copy link
Member Author

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

layout/options.go Outdated Show resolved Hide resolved
Signed-off-by: Natalie Arellano <narellano@vmware.com>
@jjbustamante
Copy link
Member

I think you are still working in some TODOs but overall it looks good to me! As always, terrific job @natalieparellano!

@natalieparellano natalieparellano marked this pull request as ready for review February 1, 2024 18:08
@natalieparellano natalieparellano requested a review from a team as a code owner February 1, 2024 18:08
…dia types (or other modifications)

are requested

Signed-off-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Copy link

codecov bot commented Feb 2, 2024

Codecov Report

Attention: 141 lines in your changes are missing coverage. Please review.

Comparison is base (faf6f39) 58.86% compared to head (a59c8b4) 59.79%.

Additional details and impacted files

Impacted file tree graph

@@            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     

@natalieparellano natalieparellano force-pushed the layout-wraps-v1 branch 2 times, most recently from 93f1d0b to 0153fc0 Compare February 2, 2024 21:13
Signed-off-by: Natalie Arellano <narellano@vmware.com>
Signed-off-by: Natalie Arellano <narellano@vmware.com>
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
Copy link
Member Author

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 {
Copy link
Member Author

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 {
Copy link
Member Author

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() {
Copy link
Member Author

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

Comment on lines -31 to -39
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
}
Copy link
Member Author

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 {
Copy link
Member Author

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

Comment on lines -144 to -145
err = image.Save()
h.AssertNil(t, err)
Copy link
Member Author

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

Comment on lines -44 to -63
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
}
}
Copy link
Member Author

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

Copy link
Member Author

@natalieparellano natalieparellano left a 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 :)

@natalieparellano natalieparellano merged commit 8ca2c95 into main Feb 5, 2024
5 checks passed
@natalieparellano natalieparellano deleted the layout-wraps-v1 branch February 5, 2024 20:18
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.

3 participants