func (cli *DogestryCli) pullImage(fromId remote.ID, imageRoot string, r remote.Remote) error { toDownload, err := cli.getLayerIdsToDownload(fromId, imageRoot, r, cli.Client) if err != nil { return err } for _, id := range toDownload { downloadPath := filepath.Join(imageRoot, string(id)) fmt.Printf("Pulling image id '%s' to: %v\n", id.Short(), downloadPath) err := r.PullImageId(id, downloadPath) if err != nil { return err } } return nil }
func (cli *DogestryCli) downloadImages(r remote.Remote, downloadMap DownloadMap, imageRoot string) error { pullImagesErrMap := make(map[string]error) for id, _ := range downloadMap { downloadPath := filepath.Join(imageRoot, string(id)) fmt.Printf("Pulling image id '%s' to: %v\n", id.Short(), downloadPath) err := r.PullImageId(id, downloadPath) if err != nil { pullImagesErrMap[downloadPath] = err } } if len(pullImagesErrMap) > 0 { fmt.Printf("Errors pulling images: %v\n", pullImagesErrMap) return fmt.Errorf("Error downloading files from S3") } return nil }