func FirstManifest(ctx context.Context, from imagereference.DockerImageReference, repo distribution.Repository, filterFn FilterFunc) (distribution.Manifest, ManifestLocation, error) {
	var srcDigest digest.Digest
	if len(from.ID) > 0 {
		srcDigest = digest.Digest(from.ID)
	} else if len(from.Tag) > 0 {
		desc, err := repo.Tags(ctx).Get(ctx, from.Tag)
		if err != nil {
			return nil, ManifestLocation{}, err
		}
		srcDigest = desc.Digest
	} else {
		return nil, ManifestLocation{}, fmt.Errorf("no tag or digest specified")
	}
	manifests, err := repo.Manifests(ctx)
	if err != nil {
		return nil, ManifestLocation{}, err
	}
	srcManifest, err := manifests.Get(ctx, srcDigest, PreferManifestList)
	if err != nil {
		return nil, ManifestLocation{}, err
	}

	originalSrcDigest := srcDigest
	srcManifests, srcManifest, srcDigest, err := ProcessManifestList(ctx, srcDigest, srcManifest, manifests, from, filterFn, false)
	if err != nil {
		return nil, ManifestLocation{}, err
	}
	if len(srcManifests) == 0 {
		return nil, ManifestLocation{}, fmt.Errorf("filtered all images from manifest list")
	}

	if srcDigest != originalSrcDigest {
		return srcManifest, ManifestLocation{Manifest: srcDigest, ManifestList: originalSrcDigest}, nil
	}
	return srcManifest, ManifestLocation{Manifest: srcDigest}, nil
}
// FirstManifest returns the first manifest at the request location that matches the filter function.
FirstManifest returns the first manifest at the request location that matches the filter function.
// FirstManifest returns the first manifest at the request location that matches the filter function .
func FirstManifest(ctx context.Context, from imagereference.DockerImageReference, repo distribution.Repository, filterFn FilterFunc) (distribution.Manifest, ManifestLocation, error) {
	var srcDigest digest.Digest
	if len(from.ID) > 0 {
		srcDigest = digest.Digest(from.ID)
	} else if len(from.Tag) > 0 {
		desc, err := repo.Tags(ctx).Get(ctx, from.Tag)
		if err != nil {
			return nil, ManifestLocation{}, err
		}
		srcDigest = desc.Digest
	} else {
		return nil, ManifestLocation{}, fmt.Errorf("no tag or digest specified")
	}
	manifests, err := repo.Manifests(ctx)
	if err != nil {
		return nil, ManifestLocation{}, err
	}
	srcManifest, err := manifests.Get(ctx, srcDigest, PreferManifestList)
	if err != nil {
		return nil, ManifestLocation{}, err
	}
	originalSrcDigest := srcDigest
	srcManifests, srcManifest, srcDigest, err := ProcessManifestList(ctx, srcDigest, srcManifest, manifests, from, filterFn, false)
	if err != nil {
		return nil, ManifestLocation{}, err
	}
	if len(srcManifests) == 0 {
		return nil, ManifestLocation{}, fmt.Errorf("filtered all images from manifest list")
	}
	if srcDigest != originalSrcDigest {
		return srcManifest, ManifestLocation{Manifest: srcDigest, ManifestList: originalSrcDigest}, nil
	}
	return srcManifest, ManifestLocation{Manifest: srcDigest}, nil
}
func FirstManifest ( ctx context . Context , from imagereference . DockerImageReference , repo distribution . Repository , filterFn FilterFunc ) ( distribution . Manifest , ManifestLocation , error ) { var srcDigest digest . Digest if len ( from . ID ) > 0 { srcDigest = digest . Digest ( from . ID ) } else if len ( from . Tag ) > 0 { desc , err := repo . Tags ( ctx ) . Get ( ctx , from . Tag ) if err != nil { return nil , ManifestLocation { } , err } srcDigest = desc . Digest } else { return nil , ManifestLocation { } , fmt . Errorf ( " " ) } manifests , err := repo . Manifests ( ctx ) if err != nil { return nil , ManifestLocation { } , err } srcManifest , err := manifests . Get ( ctx , srcDigest , PreferManifestList ) if err != nil { return nil , ManifestLocation { } , err } originalSrcDigest := srcDigest srcManifests , srcManifest , srcDigest , err := ProcessManifestList ( ctx , srcDigest , srcManifest , manifests , from , filterFn , false ) if err != nil { return nil , ManifestLocation { } , err } if len ( srcManifests ) == 0 { return nil , ManifestLocation { } , fmt . Errorf ( " " ) } if srcDigest != originalSrcDigest { return srcManifest , ManifestLocation { Manifest : srcDigest , ManifestList : originalSrcDigest } , nil } return srcManifest , ManifestLocation { Manifest : srcDigest } , nil }
FirstManifest returns the first manifest at the request location that matches the filter function.
FirstManifest returns the first manifest at the request location that matches the filter function .