Selaa lähdekoodia

Remove push by ID

Pushing by image ID is not allowed in the Docker CLI and not supported by the registry. An unnamed image also cannot be pushed to a private registry, since no endpoint is specified and it will default to the hub. The hub also does not support this use case, therefore removing the code path is the best solution.

The ability to push a layer without a name is unsupported by the v2 registry.


Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Derek McGowan 10 vuotta sitten
vanhempi
commit
db2d875b5e
1 muutettua tiedostoa jossa 14 lisäystä ja 22 poistoa
  1. 14 22
      graph/push.go

+ 14 - 22
graph/push.go

@@ -449,10 +449,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 {
@@ -466,26 +465,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
+
 }