forked from containers/common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libimage/layer_tree: if parent is empty and manifest list ignore
Layer tree expectes to form a relation between child and parent instances, however it expects an instance from manifest list which is empty, following expectation is not possible and will always resuilt in error. Closes: containers/podman#19860 [NO NEW TESTS NEEDED] Image without layer cant be built in libimage, and `podman save` automatically malforms such image so no such external image can be loaded. Signed-off-by: Aditya R <arajan@redhat.com>
- Loading branch information
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package libimage | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestListWithEmptyLayerImage(t *testing.T) { | ||
runtime, cleanup := testNewRuntime(t) | ||
defer cleanup() | ||
ctx := context.Background() | ||
loadOptions := &LoadOptions{} | ||
loadOptions.Writer = os.Stdout | ||
|
||
list, err := runtime.CreateManifestList("m") | ||
require.NoError(t, err) | ||
require.NotNil(t, list) | ||
|
||
for _, test := range []struct { | ||
input string | ||
expectError bool | ||
numImages int | ||
names []string | ||
}{ | ||
// OCI ARCHIVE | ||
{"testdata/empty_image.tar", false, 1, []string{"localhost/i:latest"}}, | ||
} { | ||
loadedImages, err := runtime.Load(ctx, test.input, loadOptions) | ||
if test.expectError { | ||
require.Error(t, err, test.input) | ||
continue | ||
} | ||
require.NoError(t, err, test.input) | ||
require.Equal(t, test.names, loadedImages, test.input) | ||
|
||
// Make sure that all returned names exist as images in the | ||
// local containers storage. | ||
ids := []string{} // later used for image removal | ||
names := [][]string{} | ||
for _, name := range loadedImages { | ||
image, resolvedName, err := runtime.LookupImage(name, nil) | ||
require.NoError(t, err, test.input) | ||
require.Equal(t, name, resolvedName, test.input) | ||
ids = append(ids, image.ID()) | ||
names = append(names, image.Names()) | ||
} | ||
} | ||
listedImages, err := runtime.ListImages(ctx, nil, &ListImagesOptions{}) | ||
require.NoError(t, err) | ||
require.Len(t, listedImages, 2, "expected 2 images") | ||
} |
Binary file not shown.