|
@@ -17,6 +17,7 @@ import (
|
|
|
"github.com/docker/docker/engine"
|
|
|
"github.com/docker/docker/image"
|
|
|
"github.com/docker/docker/pkg/progressreader"
|
|
|
+ "github.com/docker/docker/pkg/streamformatter"
|
|
|
"github.com/docker/docker/pkg/stringid"
|
|
|
"github.com/docker/docker/registry"
|
|
|
"github.com/docker/docker/runconfig"
|
|
@@ -130,7 +131,7 @@ type imagePushData struct {
|
|
|
|
|
|
// lookupImageOnEndpoint checks the specified endpoint to see if an image exists
|
|
|
// and if it is absent then it sends the image id to the channel to be pushed.
|
|
|
-func lookupImageOnEndpoint(wg *sync.WaitGroup, r *registry.Session, out io.Writer, sf *utils.StreamFormatter,
|
|
|
+func lookupImageOnEndpoint(wg *sync.WaitGroup, r *registry.Session, out io.Writer, sf *streamformatter.StreamFormatter,
|
|
|
images chan imagePushData, imagesToPush chan string) {
|
|
|
defer wg.Done()
|
|
|
for image := range images {
|
|
@@ -144,7 +145,7 @@ func lookupImageOnEndpoint(wg *sync.WaitGroup, r *registry.Session, out io.Write
|
|
|
}
|
|
|
|
|
|
func (s *TagStore) pushImageToEndpoint(endpoint string, out io.Writer, remoteName string, imageIDs []string,
|
|
|
- tags map[string][]string, repo *registry.RepositoryData, sf *utils.StreamFormatter, r *registry.Session) error {
|
|
|
+ tags map[string][]string, repo *registry.RepositoryData, sf *streamformatter.StreamFormatter, r *registry.Session) error {
|
|
|
workerCount := len(imageIDs)
|
|
|
// start a maximum of 5 workers to check if images exist on the specified endpoint.
|
|
|
if workerCount > 5 {
|
|
@@ -203,7 +204,7 @@ func (s *TagStore) pushImageToEndpoint(endpoint string, out io.Writer, remoteNam
|
|
|
// pushRepository pushes layers that do not already exist on the registry.
|
|
|
func (s *TagStore) pushRepository(r *registry.Session, out io.Writer,
|
|
|
repoInfo *registry.RepositoryInfo, localRepo map[string]string,
|
|
|
- tag string, sf *utils.StreamFormatter) error {
|
|
|
+ tag string, sf *streamformatter.StreamFormatter) error {
|
|
|
log.Debugf("Local repo: %s", localRepo)
|
|
|
out = utils.NewWriteFlusher(out)
|
|
|
imgList, tags, err := s.getImageList(localRepo, tag)
|
|
@@ -238,7 +239,7 @@ func (s *TagStore) pushRepository(r *registry.Session, out io.Writer,
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
-func (s *TagStore) pushImage(r *registry.Session, out io.Writer, imgID, ep string, token []string, sf *utils.StreamFormatter) (checksum string, err error) {
|
|
|
+func (s *TagStore) pushImage(r *registry.Session, out io.Writer, imgID, ep string, token []string, sf *streamformatter.StreamFormatter) (checksum string, err error) {
|
|
|
out = utils.NewWriteFlusher(out)
|
|
|
jsonRaw, err := ioutil.ReadFile(path.Join(s.graph.Root, imgID, "json"))
|
|
|
if err != nil {
|
|
@@ -292,7 +293,7 @@ func (s *TagStore) pushImage(r *registry.Session, out io.Writer, imgID, ep strin
|
|
|
return imgData.Checksum, nil
|
|
|
}
|
|
|
|
|
|
-func (s *TagStore) pushV2Repository(r *registry.Session, localRepo Repository, out io.Writer, repoInfo *registry.RepositoryInfo, tag string, sf *utils.StreamFormatter) error {
|
|
|
+func (s *TagStore) pushV2Repository(r *registry.Session, localRepo Repository, out io.Writer, repoInfo *registry.RepositoryInfo, tag string, sf *streamformatter.StreamFormatter) error {
|
|
|
endpoint, err := r.V2RegistryEndpoint(repoInfo.Index)
|
|
|
if err != nil {
|
|
|
if repoInfo.Index.Official {
|
|
@@ -442,7 +443,7 @@ func (s *TagStore) pushV2Repository(r *registry.Session, localRepo Repository, o
|
|
|
}
|
|
|
|
|
|
// PushV2Image pushes the image content to the v2 registry, first buffering the contents to disk
|
|
|
-func (s *TagStore) pushV2Image(r *registry.Session, img *image.Image, endpoint *registry.Endpoint, imageName string, sf *utils.StreamFormatter, out io.Writer, auth *registry.RequestAuthorization) (string, error) {
|
|
|
+func (s *TagStore) pushV2Image(r *registry.Session, img *image.Image, endpoint *registry.Endpoint, imageName string, sf *streamformatter.StreamFormatter, out io.Writer, auth *registry.RequestAuthorization) (string, error) {
|
|
|
out.Write(sf.FormatProgress(stringid.TruncateID(img.ID), "Buffering to Disk", nil))
|
|
|
|
|
|
image, err := s.graph.Get(img.ID)
|
|
@@ -498,7 +499,7 @@ func (s *TagStore) CmdPush(job *engine.Job) error {
|
|
|
}
|
|
|
var (
|
|
|
localName = job.Args[0]
|
|
|
- sf = utils.NewStreamFormatter(job.GetenvBool("json"))
|
|
|
+ sf = streamformatter.NewStreamFormatter(job.GetenvBool("json"))
|
|
|
authConfig = ®istry.AuthConfig{}
|
|
|
metaHeaders map[string][]string
|
|
|
)
|