github.com/antevens/oras@v0.8.1/pkg/auth/docker/logout.go (about) 1 package docker 2 3 import ( 4 "context" 5 6 "github.com/deislabs/oras/pkg/auth" 7 8 "github.com/docker/cli/cli/config/configfile" 9 ) 10 11 // Logout logs out from a docker registry identified by the hostname. 12 func (c *Client) Logout(_ context.Context, hostname string) error { 13 hostname = resolveHostname(hostname) 14 15 var configs []*configfile.ConfigFile 16 for _, config := range c.configs { 17 if _, ok := config.AuthConfigs[hostname]; ok { 18 configs = append(configs, config) 19 } 20 } 21 if len(configs) == 0 { 22 return auth.ErrNotLoggedIn 23 } 24 25 // Log out form the primary config only as backups are read-only. 26 return c.primaryCredentialsStore(hostname).Erase(hostname) 27 }