Exemple #1
0
func (srv *Server) pushRepository(r *registry.Registry, out io.Writer, name string, localRepo map[string]string) error {
	out = utils.NewWriteFlusher(out)
	fmt.Fprintf(out, "Processing checksums\n")
	imgList, err := srv.getImageList(localRepo)
	if err != nil {
		return err
	}
	fmt.Fprintf(out, "Sending images list\n")

	repoData, err := r.PushImageJsonIndex(name, imgList, false)
	if err != nil {
		return err
	}

	for _, ep := range repoData.Endpoints {
		fmt.Fprintf(out, "Pushing repository %s to %s (%d tags)\r\n", name, ep, len(localRepo))
		// For each image within the repo, push them
		for _, elem := range imgList {
			if _, exists := repoData.ImgList[elem.Id]; exists {
				fmt.Fprintf(out, "Image %s already on registry, skipping\n", name)
				continue
			}
			if err := srv.pushImage(r, out, name, elem.Id, ep, repoData.Tokens); err != nil {
				// FIXME: Continue on error?
				return err
			}
			fmt.Fprintf(out, "Pushing tags for rev [%s] on {%s}\n", elem.Id, ep+"/users/"+name+"/"+elem.Tag)
			if err := r.PushRegistryTag(name, elem.Id, elem.Tag, ep, repoData.Tokens); err != nil {
				return err
			}
		}
	}

	if _, err := r.PushImageJsonIndex(name, imgList, true); err != nil {
		return err
	}
	return nil
}