mirror of https://github.com/docker/cli.git
Remove cli/command/credentials
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
ed55f00674
commit
4ae4e66e3c
|
@ -1,37 +0,0 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/cliconfig/configfile"
|
||||
"github.com/docker/docker/cliconfig/credentials"
|
||||
)
|
||||
|
||||
// GetCredentials loads the user credentials from a credentials store.
|
||||
// The store is determined by the config file settings.
|
||||
func GetCredentials(c *configfile.ConfigFile, serverAddress string) (types.AuthConfig, error) {
|
||||
s := LoadCredentialsStore(c)
|
||||
return s.Get(serverAddress)
|
||||
}
|
||||
|
||||
// StoreCredentials saves the user credentials in a credentials store.
|
||||
// The store is determined by the config file settings.
|
||||
func StoreCredentials(c *configfile.ConfigFile, auth types.AuthConfig) error {
|
||||
s := LoadCredentialsStore(c)
|
||||
return s.Store(auth)
|
||||
}
|
||||
|
||||
// EraseCredentials removes the user credentials from a credentials store.
|
||||
// The store is determined by the config file settings.
|
||||
func EraseCredentials(c *configfile.ConfigFile, serverAddress string) error {
|
||||
s := LoadCredentialsStore(c)
|
||||
return s.Erase(serverAddress)
|
||||
}
|
||||
|
||||
// LoadCredentialsStore initializes a new credentials store based
|
||||
// in the settings provided in the configuration file.
|
||||
func LoadCredentialsStore(c *configfile.ConfigFile) credentials.Store {
|
||||
if c.CredentialsStore != "" {
|
||||
return credentials.NewNativeStore(c)
|
||||
}
|
||||
return credentials.NewFileStore(c)
|
||||
}
|
|
@ -36,7 +36,6 @@ func (cli *DockerCli) ElectAuthServer(ctx context.Context) string {
|
|||
}
|
||||
|
||||
// EncodeAuthToBase64 serializes the auth configuration as JSON base64 payload
|
||||
// TODO: move to client/encode ?
|
||||
func EncodeAuthToBase64(authConfig types.AuthConfig) (string, error) {
|
||||
buf, err := json.Marshal(authConfig)
|
||||
if err != nil {
|
||||
|
@ -71,7 +70,7 @@ func (cli *DockerCli) ResolveAuthConfig(ctx context.Context, index *registrytype
|
|||
configKey = cli.ElectAuthServer(ctx)
|
||||
}
|
||||
|
||||
a, _ := GetCredentials(cli.configFile, configKey)
|
||||
a, _ := cli.CredentialsStore().Get(configKey)
|
||||
return a
|
||||
}
|
||||
|
||||
|
@ -87,7 +86,7 @@ func (cli *DockerCli) ConfigureAuth(flUser, flPassword, serverAddress string, is
|
|||
serverAddress = registry.ConvertToHostname(serverAddress)
|
||||
}
|
||||
|
||||
authconfig, err := GetCredentials(cli.configFile, serverAddress)
|
||||
authconfig, err := cli.CredentialsStore().Get(serverAddress)
|
||||
if err != nil {
|
||||
return authconfig, err
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ func runLogin(dockerCli *command.DockerCli, opts loginOptions) error {
|
|||
authConfig.Password = ""
|
||||
authConfig.IdentityToken = response.IdentityToken
|
||||
}
|
||||
if err := command.StoreCredentials(dockerCli.ConfigFile(), authConfig); err != nil {
|
||||
if err := dockerCli.CredentialsStore().Store(authConfig); err != nil {
|
||||
return fmt.Errorf("Error saving credentials: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ func runLogout(dockerCli *command.DockerCli, serverAddress string) error {
|
|||
|
||||
fmt.Fprintf(dockerCli.Out(), "Removing login credentials for %s\n", hostnameAddress)
|
||||
for _, r := range regsToLogout {
|
||||
if err := command.EraseCredentials(dockerCli.ConfigFile(), r); err != nil {
|
||||
if err := dockerCli.CredentialsStore().Erase(r); err != nil {
|
||||
fmt.Fprintf(dockerCli.Err(), "WARNING: could not erase credentials: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue