func (idx *Index) GetImage(repository, tag string, dg digest.Digest) (*dim.IndexImage, error) {
	named, _ := reference.ParseNamed(repository)
	var repo dim.Repository
	var err error
	if repo, err = idx.RegClient.NewRepository(named); err != nil {
		logrus.WithError(err).WithField("Repository", repository).Errorln("Failed get repository info")
		return nil, err
	}
	var img *dim.RegistryImage
	if img, err = repo.ImageFromManifest(dg, tag); err != nil {
		logrus.WithError(err).Errorln("Failed to get image info from manifest")
		return nil, err
	}
	return Parse(repository, img), nil
}
GetImage returns the docker image ready to be indexed
package index
import (
	"fmt"
	"strings"
	"sync"
	"time"
	"github.com/Sirupsen/logrus"
	"github.com/blevesearch/bleve"
	"github.com/blevesearch/bleve/search"
	"github.com/docker/distribution/digest"
	"github.com/docker/docker/reference"
	"github.com/nhurel/dim/lib"
	"github.com/nhurel/dim/lib/utils"
)
type Index struct {
	bleve.Index
	Config        *Config
	RegClient     dim.RegistryClient
	notifications chan *dim.NotificationJob
}
type repoImage struct {
	repoName string
	image    *dim.RegistryImage
}
func New(cfg *Config, regClient dim.RegistryClient) (*Index, error) {
	var i bleve.Index
	var err error
	mapping := bleve.NewIndexMapping()
	mapping.AddDocumentMapping("image", ImageMapping)
	if i, err = bleve.New(cfg.Directory, mapping); err != nil {
		return nil, err
	}
	notifications := make(chan *dim.NotificationJob, 3)
	index := &Index{Index: i, RegClient: regClient, notifications: notifications, Config: cfg}
	index.loop(3)
	return index, nil
}
func (idx *Index) Build() <-chan bool {
	done := make(chan bool, 1)
	go func() {
		repositories := idx.RegClient.WalkRepositories()
		images := make(chan *repoImage, 10)
		browseImgWg := sync.WaitGroup{}
		for repository := range repositories {
			browseImgWg.Add(1)
			go func(repo dim.Repository) {
				defer browseImgWg.Done()
				for img := range repo.WalkImages() {
					images <- &repoImage{repo.Named().Name(), img}
				}
			}(repository)
		}
		tasks := make(chan *dim.IndexImage, 5)
		parseImgWg := sync.WaitGroup{}
		parseImgWg.Add(3)
		for i := 0; i < 3; i++ {
			go func() {
				defer parseImgWg.Done()
				for img := range images {
					logrus.WithField("reponame", img.repoName).Infoln("Indexing image")
					tasks <- Parse(img.repoName, img.image)
				}
			}()
		}
		batch := idx.NewBatch()
		go func() {
			for task := range tasks {
				batch.Index(task.FullName, task)
			}
			if err := idx.Batch(batch); err != nil {
				logrus.WithError(err).Errorln("Failed to index initial repository state")
			}
			close(done)
		}()
		browseImgWg.Wait()
		close(images)
		parseImgWg.Wait()
		close(tasks)
	}()
	return done
}