Skip to content

Commit

Permalink
Fix a bug while auto-updating service images, as we were updating a c…
Browse files Browse the repository at this point in the history
…opy of the image instead of a reference

Add regression test

Signed-off-by: Silvin Lubecki <[email protected]>
  • Loading branch information
silvin-lubecki committed Sep 10, 2019
1 parent 1552fad commit 7b5c27b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion remotes/fixup.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ func FixupBundle(ctx context.Context, b *bundle.Bundle, ref reference.Named, res
return nil, err
}
// Fixup images
for _, original := range b.Images {
for name, original := range b.Images {
if err := fixupImage(ctx, &original.BaseImage, relocationMap, cfg, events, cfg.componentImagePlatformFilter); err != nil {
return nil, err
}
b.Images[name] = original
}

logger.Debug("Bundle fixed")
Expand Down
27 changes: 27 additions & 0 deletions remotes/fixup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ func TestFixupBundleWithAutoUpdate(t *testing.T) {
},
// Target Invocation image manifest descriptor my.registry/namespace/my-app@sha256:beef1aa7866258751a261bae525a1842c7ff0662d4f34a355d5f36826abc0343 for mounting
{},
// Resolving source service image manifest descriptor my.registry/namespace/my-service
{
MediaType: ocischemav1.MediaTypeImageManifest,
Size: 43,
Digest: "sha256:beef1aa7866258751a261bae525a1842c7ff0662d4f34a355d5f36826abc0344",
},
// Target service image manifest descriptor my.registry/namespace/my-app@sha256:beef1aa7866258751a261bae525a1842c7ff0662d4f34a355d5f36826abc0344 for mounting
{},
},
}
b := &bundle.Bundle{
Expand All @@ -52,6 +60,14 @@ func TestFixupBundleWithAutoUpdate(t *testing.T) {
},
},
},
Images: map[string]bundle.Image{
"my-service": {
BaseImage: bundle.BaseImage{
Image: "my.registry/namespace/my-service",
ImageType: "docker",
},
},
},
Name: "my-app",
Version: "0.1.0",
}
Expand All @@ -72,6 +88,17 @@ func TestFixupBundleWithAutoUpdate(t *testing.T) {
},
},
},
Images: map[string]bundle.Image{
"my-service": {
BaseImage: bundle.BaseImage{
Image: "my.registry/namespace/my-service",
ImageType: "docker",
MediaType: ocischemav1.MediaTypeImageManifest,
Size: 43,
Digest: "sha256:beef1aa7866258751a261bae525a1842c7ff0662d4f34a355d5f36826abc0344",
},
},
},
Name: "my-app",
Version: "0.1.0",
}
Expand Down

0 comments on commit 7b5c27b

Please sign in to comment.