From 161526d99d6543341b8651ab5c7ac1e503abb79f Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Mon, 25 Mar 2013 21:01:42 -0700 Subject: [PATCH] Add a lookup before pushing repository to check permissions --- registry.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/registry.go b/registry.go index c7dd23b850..c75a1aafe3 100644 --- a/registry.go +++ b/registry.go @@ -370,11 +370,10 @@ func (graph *Graph) pushPrimitive(stdout io.Writer, remote, tag, imgId string, a // Push a repository to the registry. // Remote has the format '/ func (graph *Graph) PushRepository(stdout io.Writer, remote string, localRepo Repository, authConfig *auth.AuthConfig) error { - // Check if the remote repository exists - // FIXME: @lopter How to handle this? - // if !graph.LookupRemoteRepository(remote, authConfig) { - // return fmt.Errorf("The remote repository %s does not exist\n", remote) - // } + // Check if the remote repository exists/if we have the permission + if !graph.LookupRemoteRepository(remote, authConfig) { + return fmt.Errorf("Permission denied on repository %s\n", remote) + } fmt.Fprintf(stdout, "Pushing repository %s (%d tags)\n", remote, len(localRepo)) // For each image within the repo, push them