Files
moby/internal/testutils/specialimage/emptyindex.go
Paweł Gronowski 153de36b3f c8d/list: Add empty index test case
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-03-18 12:50:10 +01:00

26 lines
672 B
Go

package specialimage
import (
"github.com/distribution/reference"
"github.com/opencontainers/image-spec/specs-go"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
// EmptyIndex creates an image index with no manifests.
// This is equivalent to `tianon/scratch:index`.
func EmptyIndex(dir string) (*ocispec.Index, error) {
const imageRef = "emptyindex:latest"
index := ocispec.Index{
Versioned: specs.Versioned{SchemaVersion: 2},
MediaType: ocispec.MediaTypeImageIndex,
Manifests: []ocispec.Descriptor{},
}
ref, err := reference.ParseNormalizedNamed(imageRef)
if err != nil {
return nil, err
}
return multiPlatformImage(dir, ref, index)
}