// TODO: add tag support
add tag support
// TODO : add tag support
func pullHandler(w http.ResponseWriter, r *http.Request, c *Context) {
	vars := mux.Vars(r)
	remote := vars["remote"]
	repoData, err := c.Registry.GetRepositoryData(remote)
	if err != nil {
		log.Fatal(err)
	}
	tagsList, err := c.Registry.GetRemoteTags(repoData.Endpoints, remote, repoData.Tokens)
	if err != nil {
		log.Fatal(err)
	}
	for tag, id := range tagsList {
		repoData.ImgList[id].Tag = tag
	}
	for _, img := range repoData.ImgList {
		log.Printf("Pulling image %s (%s) from %s\n", img.ID, img.Tag, remote)
		success := false
		for _, ep := range repoData.Endpoints {
			if err := pullImage(c, img.ID, "https://"+ep+"/v1", repoData.Tokens); err != nil {
				fmt.Printf("Error while retrieving image for tag: %s; checking next endpoint\n", err)
				continue
			}
			success = true
			break
		}
		if !success {
			log.Fatal("Could not find repository on any of the indexed registries.")
		}
	}
	for tag, id := range tagsList {
		if err := c.Repositories.Set(remote, tag, id, true); err != nil {
			log.Fatal(err)
			return
		}
	}
	if err := c.Repositories.Save(); err != nil {
		log.Fatal(err)
		return
	}
	fmt.Fprintf(w, "%v\n", repoData)
}
func pullHandler ( w http . ResponseWriter , r * http . Request , c * Context ) { vars := mux . Vars ( r ) remote := vars [ " " ] repoData , err := c . Registry . GetRepositoryData ( remote ) if err != nil { log . Fatal ( err ) } tagsList , err := c . Registry . GetRemoteTags ( repoData . Endpoints , remote , repoData . Tokens ) if err != nil { log . Fatal ( err ) } for tag , id := range tagsList { repoData . ImgList [ id ] . Tag = tag } for _ , img := range repoData . ImgList { log . Printf ( " \n " , img . ID , img . Tag , remote ) success := false for _ , ep := range repoData . Endpoints { if err := pullImage ( c , img . ID , " " + ep + " " , repoData . Tokens ) ; err != nil { fmt . Printf ( " \n " , err ) continue } success = true break } if ! success { log . Fatal ( " " ) } } for tag , id := range tagsList { if err := c . Repositories . Set ( remote , tag , id , true ) ; err != nil { log . Fatal ( err ) return } } if err := c . Repositories . Save ( ) ; err != nil { log . Fatal ( err ) return } fmt . Fprintf ( w , " \n " , repoData ) }
add tag support
add tag support