Skip to content

Commit

Permalink
Merge pull request moby#10694 from dmcgowan/remove-push-by-id
Browse files Browse the repository at this point in the history
Remove push by ID
  • Loading branch information
crosbymichael committed Feb 12, 2015
2 parents f4749ac + db2d875 commit 3eb1939
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions graph/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,9 @@ func (s *TagStore) CmdPush(job *engine.Job) engine.Status {
return job.Error(err)
}

img, err := s.graph.Get(repoInfo.LocalName)
r, err2 := registry.NewSession(authConfig, registry.HTTPRequestFactory(metaHeaders), endpoint, false)
if err2 != nil {
return job.Error(err2)
r, err := registry.NewSession(authConfig, registry.HTTPRequestFactory(metaHeaders), endpoint, false)
if err != nil {
return job.Error(err)
}

if endpoint.Version == registry.APIVersion2 {
Expand All @@ -468,26 +467,19 @@ func (s *TagStore) CmdPush(job *engine.Job) engine.Status {
}
}

if err != nil {
reposLen := 1
if tag == "" {
reposLen = len(s.Repositories[repoInfo.LocalName])
}
job.Stdout.Write(sf.FormatStatus("", "The push refers to a repository [%s] (len: %d)", repoInfo.CanonicalName, reposLen))
// If it fails, try to get the repository
if localRepo, exists := s.Repositories[repoInfo.LocalName]; exists {
if err := s.pushRepository(r, job.Stdout, repoInfo, localRepo, tag, sf); err != nil {
return job.Error(err)
}
return engine.StatusOK
}
return job.Error(err)
reposLen := 1
if tag == "" {
reposLen = len(s.Repositories[repoInfo.LocalName])
}

var token []string
job.Stdout.Write(sf.FormatStatus("", "The push refers to an image: [%s]", repoInfo.CanonicalName))
if _, err := s.pushImage(r, job.Stdout, img.ID, endpoint.String(), token, sf); err != nil {
job.Stdout.Write(sf.FormatStatus("", "The push refers to a repository [%s] (len: %d)", repoInfo.CanonicalName, reposLen))
// If it fails, try to get the repository
localRepo, exists := s.Repositories[repoInfo.LocalName]
if !exists {
return job.Errorf("Repository does not exist: %s", repoInfo.LocalName)
}
if err := s.pushRepository(r, job.Stdout, repoInfo, localRepo, tag, sf); err != nil {
return job.Error(err)
}
return engine.StatusOK

}

0 comments on commit 3eb1939

Please sign in to comment.