Skip to content

Commit

Permalink
fix: use Docker image index and manifests
Browse files Browse the repository at this point in the history
Empty image sets Docker manifest schema
and not OCI. Image manifests included in
OCI image index, and to keep consistency
all of them should have Docker media types.

Signed-off-by: Ben Oukhanov <[email protected]>
  • Loading branch information
codingben committed Mar 28, 2024
1 parent f03886c commit 6c2bc6b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/google/go-containerregistry/pkg/v1/mutate"
"github.com/google/go-containerregistry/pkg/v1/partial"
"github.com/google/go-containerregistry/pkg/v1/tarball"
"github.com/google/go-containerregistry/pkg/v1/types"
)

const (
Expand All @@ -29,12 +30,12 @@ func ContainerDiskConfig(checksum string, envVariables map[string]string) v1.Con
}

func ContainerDisk(imgPath, imgArch string, config v1.Config) (v1.Image, error) {
img := empty.Image
layer, err := tarball.LayerFromOpener(StreamLayerOpener(imgPath))
if err != nil {
return nil, fmt.Errorf("error creating an image layer from disk: %v", err)
}

img := mutate.MediaType(empty.Image, types.DockerManifestSchema2)
img, err = mutate.AppendLayers(img, layer)
if err != nil {
return nil, fmt.Errorf("error appending the image layer: %v", err)
Expand Down Expand Up @@ -79,5 +80,6 @@ func ContainerDiskIndex(images []v1.Image) (v1.ImageIndex, error) {
})
}

return mutate.AppendManifests(empty.Index, indexAddendum...), nil
idx := mutate.IndexMediaType(empty.Index, types.DockerManifestList)
return mutate.AppendManifests(idx, indexAddendum...), nil
}

0 comments on commit 6c2bc6b

Please sign in to comment.