Signed-off-by: Daniel Nephin <dnephin@docker.com>
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,37 +0,0 @@ |
| 1 |
-package command |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "github.com/docker/docker/api/types" |
|
| 5 |
- "github.com/docker/docker/cliconfig/configfile" |
|
| 6 |
- "github.com/docker/docker/cliconfig/credentials" |
|
| 7 |
-) |
|
| 8 |
- |
|
| 9 |
-// GetCredentials loads the user credentials from a credentials store. |
|
| 10 |
-// The store is determined by the config file settings. |
|
| 11 |
-func GetCredentials(c *configfile.ConfigFile, serverAddress string) (types.AuthConfig, error) {
|
|
| 12 |
- s := LoadCredentialsStore(c) |
|
| 13 |
- return s.Get(serverAddress) |
|
| 14 |
-} |
|
| 15 |
- |
|
| 16 |
-// StoreCredentials saves the user credentials in a credentials store. |
|
| 17 |
-// The store is determined by the config file settings. |
|
| 18 |
-func StoreCredentials(c *configfile.ConfigFile, auth types.AuthConfig) error {
|
|
| 19 |
- s := LoadCredentialsStore(c) |
|
| 20 |
- return s.Store(auth) |
|
| 21 |
-} |
|
| 22 |
- |
|
| 23 |
-// EraseCredentials removes the user credentials from a credentials store. |
|
| 24 |
-// The store is determined by the config file settings. |
|
| 25 |
-func EraseCredentials(c *configfile.ConfigFile, serverAddress string) error {
|
|
| 26 |
- s := LoadCredentialsStore(c) |
|
| 27 |
- return s.Erase(serverAddress) |
|
| 28 |
-} |
|
| 29 |
- |
|
| 30 |
-// LoadCredentialsStore initializes a new credentials store based |
|
| 31 |
-// in the settings provided in the configuration file. |
|
| 32 |
-func LoadCredentialsStore(c *configfile.ConfigFile) credentials.Store {
|
|
| 33 |
- if c.CredentialsStore != "" {
|
|
| 34 |
- return credentials.NewNativeStore(c) |
|
| 35 |
- } |
|
| 36 |
- return credentials.NewFileStore(c) |
|
| 37 |
-} |
| ... | ... |
@@ -36,7 +36,6 @@ func (cli *DockerCli) ElectAuthServer(ctx context.Context) string {
|
| 36 | 36 |
} |
| 37 | 37 |
|
| 38 | 38 |
// EncodeAuthToBase64 serializes the auth configuration as JSON base64 payload |
| 39 |
-// TODO: move to client/encode ? |
|
| 40 | 39 |
func EncodeAuthToBase64(authConfig types.AuthConfig) (string, error) {
|
| 41 | 40 |
buf, err := json.Marshal(authConfig) |
| 42 | 41 |
if err != nil {
|
| ... | ... |
@@ -71,7 +70,7 @@ func (cli *DockerCli) ResolveAuthConfig(ctx context.Context, index *registrytype |
| 71 | 71 |
configKey = cli.ElectAuthServer(ctx) |
| 72 | 72 |
} |
| 73 | 73 |
|
| 74 |
- a, _ := GetCredentials(cli.configFile, configKey) |
|
| 74 |
+ a, _ := cli.CredentialsStore().Get(configKey) |
|
| 75 | 75 |
return a |
| 76 | 76 |
} |
| 77 | 77 |
|
| ... | ... |
@@ -87,7 +86,7 @@ func (cli *DockerCli) ConfigureAuth(flUser, flPassword, serverAddress string, is |
| 87 | 87 |
serverAddress = registry.ConvertToHostname(serverAddress) |
| 88 | 88 |
} |
| 89 | 89 |
|
| 90 |
- authconfig, err := GetCredentials(cli.configFile, serverAddress) |
|
| 90 |
+ authconfig, err := cli.CredentialsStore().Get(serverAddress) |
|
| 91 | 91 |
if err != nil {
|
| 92 | 92 |
return authconfig, err |
| 93 | 93 |
} |
| ... | ... |
@@ -74,7 +74,7 @@ func runLogin(dockerCli *command.DockerCli, opts loginOptions) error {
|
| 74 | 74 |
authConfig.Password = "" |
| 75 | 75 |
authConfig.IdentityToken = response.IdentityToken |
| 76 | 76 |
} |
| 77 |
- if err := command.StoreCredentials(dockerCli.ConfigFile(), authConfig); err != nil {
|
|
| 77 |
+ if err := dockerCli.CredentialsStore().Store(authConfig); err != nil {
|
|
| 78 | 78 |
return fmt.Errorf("Error saving credentials: %v", err)
|
| 79 | 79 |
} |
| 80 | 80 |
|
| ... | ... |
@@ -68,7 +68,7 @@ func runLogout(dockerCli *command.DockerCli, serverAddress string) error {
|
| 68 | 68 |
|
| 69 | 69 |
fmt.Fprintf(dockerCli.Out(), "Removing login credentials for %s\n", hostnameAddress) |
| 70 | 70 |
for _, r := range regsToLogout {
|
| 71 |
- if err := command.EraseCredentials(dockerCli.ConfigFile(), r); err != nil {
|
|
| 71 |
+ if err := dockerCli.CredentialsStore().Erase(r); err != nil {
|
|
| 72 | 72 |
fmt.Fprintf(dockerCli.Err(), "WARNING: could not erase credentials: %v\n", err) |
| 73 | 73 |
} |
| 74 | 74 |
} |