예제 #1
0
파일: pull.go 프로젝트: wolfeidau/dogestry
func (cli *DogestryCli) preparePullImage(fromId remote.ID, imageRoot string, r remote.Remote) error {
	toDownload := make([]remote.ID, 0)

	// TODO flatten this list, then iterate and pull each required file
	// TODO parallelize
	err := r.WalkImages(fromId, func(id remote.ID, image docker.Image, err error) error {
		fmt.Printf("examining id '%s' on remote\n", id.Short())
		if err != nil {
			fmt.Println("err", err)
			return err
		}

		_, err = cli.client.InspectImage(string(id))
		if err == docker.ErrNoSuchImage {
			toDownload = append(toDownload, id)
			return nil
		} else {
			fmt.Printf("docker already has id '%s', stopping\n", id.Short())
			return remote.BreakWalk
		}
	})

	if err != nil {
		return err
	}

	for _, id := range toDownload {
		if err := cli.pullImage(id, filepath.Join(imageRoot, string(id)), r); err != nil {
			return err
		}
	}

	return nil
}
예제 #2
0
파일: pull.go 프로젝트: wolfeidau/dogestry
func (cli *DogestryCli) pullImage(id remote.ID, dst string, r remote.Remote) error {
	fmt.Printf("pulling image id '%s'\n", id.Short())

	// XXX fix image name rewrite
	err := r.PullImageId(id, dst)
	if err != nil {
		return err
	}
	return cli.processPulled(id, dst)
}
예제 #3
0
파일: pull.go 프로젝트: wolfeidau/dogestry
func prepareRepositories(image, imageRoot string, r remote.Remote) error {
	repoName, repoTag := remote.NormaliseImageName(image)

	id, err := r.ParseTag(repoName, repoTag)
	if err != nil {
		return err
	} else if id == "" {
		return nil
	}

	reposPath := filepath.Join(imageRoot, "repositories")
	reposFile, err := os.Create(reposPath)
	if err != nil {
		return err
	}
	defer reposFile.Close()

	repositories := map[string]Repository{}
	repositories[repoName] = Repository{}
	repositories[repoName][repoTag] = string(id)

	return json.NewEncoder(reposFile).Encode(&repositories)
}