1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #10469 from dmcgowan/v2-registry-push-fallback

Add push fallback to v1 for the official registry
This commit is contained in:
Arnaud Porterie 2015-01-30 16:43:23 -08:00
commit bb4d24de06

View file

@ -2,6 +2,7 @@ package graph
import ( import (
"bytes" "bytes"
"errors"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
@ -18,6 +19,8 @@ import (
"github.com/docker/libtrust" "github.com/docker/libtrust"
) )
var ErrV2RegistryUnavailable = errors.New("error v2 registry unavailable")
// Retrieve the all the images to be uploaded in the correct order // Retrieve the all the images to be uploaded in the correct order
func (s *TagStore) getImageList(localRepo map[string]string, requestedTag string) ([]string, map[string][]string, error) { func (s *TagStore) getImageList(localRepo map[string]string, requestedTag string) ([]string, map[string][]string, error) {
var ( var (
@ -280,6 +283,10 @@ func (s *TagStore) pushV2Repository(r *registry.Session, eng *engine.Engine, out
endpoint, err := r.V2RegistryEndpoint(repoInfo.Index) endpoint, err := r.V2RegistryEndpoint(repoInfo.Index)
if err != nil { if err != nil {
if repoInfo.Index.Official {
log.Infof("Unable to push to V2 registry, falling back to v1: %s", err)
return ErrV2RegistryUnavailable
}
return fmt.Errorf("error getting registry endpoint: %s", err) return fmt.Errorf("error getting registry endpoint: %s", err)
} }
@ -454,9 +461,10 @@ func (s *TagStore) CmdPush(job *engine.Job) engine.Status {
return engine.StatusOK return engine.StatusOK
} }
// error out, no fallback to V1 if err != ErrV2RegistryUnavailable {
return job.Errorf("Error pushing to registry: %s", err) return job.Errorf("Error pushing to registry: %s", err)
} }
}
if err != nil { if err != nil {
reposLen := 1 reposLen := 1