Skip to content

Commit

Permalink
add support for index
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpect committed May 23, 2024
1 parent 187106d commit 08c9137
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions pkg/imgpkg/imagetar/tar_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ func (r TarReader) ReadOci(importRepo name.Repository) ([]imagedesc.ImageOrIndex
var ImageIntermediate imagedesc.ImageIntermediate
var ImageIndexIntermediate imagedesc.ImageIndexIntermediate
var ref string
imageOrIndex := imagedesc.ImageOrIndex{
Image: nil,
Index: nil,
Labels: map[string]string{
"dev.carvel.imgpkg.copy.root-bundle": "",
},
OrigRef: "",
}

if desc.MediaType.IsImage() {
img, err := ii.Image(desc.Digest)
Expand All @@ -90,6 +98,9 @@ func (r TarReader) ReadOci(importRepo name.Repository) ([]imagedesc.ImageOrIndex

ImageIntermediate.SetRef(ref)

var b imagedesc.ImageWithRef = ImageIntermediate
imageOrIndex.Image = &b

} else if desc.MediaType.IsIndex() {
idx, err := ii.ImageIndex(desc.Digest)
if err != nil {
Expand All @@ -107,20 +118,13 @@ func (r TarReader) ReadOci(importRepo name.Repository) ([]imagedesc.ImageOrIndex
ref = importRepo.Name() + "@" + digestStr
ImageIndexIntermediate.SetRef(ref)

var b imagedesc.ImageIndexWithRef = ImageIndexIntermediate
imageOrIndex.Index = &b

} else {
return nil, fmt.Errorf("Unexpected media type: %s", desc.MediaType)
}

var b imagedesc.ImageWithRef = ImageIntermediate
imageOrIndex := imagedesc.ImageOrIndex{
Image: &b,
Index: nil,
Labels: map[string]string{
"dev.carvel.imgpkg.copy.root-bundle": "",
},
OrigRef: "",
}

var imageOrIndexSlice []imagedesc.ImageOrIndex
imageOrIndexSlice = append(imageOrIndexSlice, imageOrIndex)

Expand Down

0 comments on commit 08c9137

Please sign in to comment.