Fix possible runtime panic if image history len is zero
We now return an empty string for the `Comment` field if an OCI v1 image
contains no history.
@@ -1298,8 +1298,11 @@ func (i *Image) Comment(ctx context.Context, manifestType string) (string, error
if err != nil {
return "", err
}
+ if len(ociv1Img.History) > 0 {
return ociv1Img.History[0].Comment, nil
}
+ return "", nil
+}
// Save writes a container image to the filesystem
func (i *Image) Save(ctx context.Context, source, format, output string, moreTags []string, quiet, compress bool) error {
