github.com/moby/docker@v26.1.3+incompatible/internal/testutils/specialimage/emptyindex.go (about)

     1  package specialimage
     2  
     3  import (
     4  	"github.com/distribution/reference"
     5  	"github.com/opencontainers/image-spec/specs-go"
     6  	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
     7  )
     8  
     9  // EmptyIndex creates an image index with no manifests.
    10  // This is equivalent to `tianon/scratch:index`.
    11  func EmptyIndex(dir string) (*ocispec.Index, error) {
    12  	const imageRef = "emptyindex:latest"
    13  
    14  	index := ocispec.Index{
    15  		Versioned: specs.Versioned{SchemaVersion: 2},
    16  		MediaType: ocispec.MediaTypeImageIndex,
    17  		Manifests: []ocispec.Descriptor{},
    18  	}
    19  
    20  	ref, err := reference.ParseNormalizedNamed(imageRef)
    21  	if err != nil {
    22  		return nil, err
    23  	}
    24  	return multiPlatformImage(dir, ref, index)
    25  }