Skip to content

Commit

Permalink
Re-write the registry logout command to not shell out to the Docker b…
Browse files Browse the repository at this point in the history
…inary.
  • Loading branch information
andrewsomething committed May 19, 2020
1 parent 93b5b12 commit 3af8147
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions commands/registry.go
Expand Up @@ -341,16 +341,17 @@ func RunDockerConfig(c *CmdConfig) error {

// RunRegistryLogout logs Docker out of the registry
func RunRegistryLogout(c *CmdConfig) error {
// check if docker is installed
if _, err := exec.LookPath("docker"); err != nil {
return fmt.Errorf("unable to find the Docker CLI binary. Make sure docker is installed")
}
server := c.Registry().Endpoint()
fmt.Printf("Removing login credentials for %s\n", server)

cmd := execCommand("docker", "logout", c.Registry().Endpoint())
cmd.Stdout = c.Out
cmd.Stderr = c.Out
cf := dockerconf.LoadDefaultConfigFile(os.Stderr)
dockerCreds := cf.GetCredentialsStore(server)
err := dockerCreds.Erase(server)
if err != nil {
return err
}

return cmd.Run()
return nil
}

// Repository Run Commands
Expand Down

0 comments on commit 3af8147

Please sign in to comment.