MCPcopy Create free account
hub / github.com/docker/cli / Store

Method Store

cli/config/credentials/file_store.go:80–100  ·  view source on GitHub ↗

Store saves the given credentials in the file store. This function is idempotent and does not update the file if credentials did not change.

(authConfig types.AuthConfig)

Source from the content-addressed store, hash-verified

78// Store saves the given credentials in the file store. This function is
79// idempotent and does not update the file if credentials did not change.
80func (c *fileStore) Store(authConfig types.AuthConfig) error {
81 authConfigs := c.file.GetAuthConfigs()
82 if oldAuthConfig, ok := authConfigs[authConfig.ServerAddress]; ok && oldAuthConfig == authConfig {
83 // Credentials didn't change, so skip updating the configuration file.
84 return nil
85 }
86 authConfigs[authConfig.ServerAddress] = authConfig
87 if err := c.file.Save(); err != nil {
88 return err
89 }
90
91 if !alreadyPrinted.Load() && authConfig.Password != "" {
92 // Display a warning if we're storing the users password (not a token).
93 //
94 // FIXME(thaJeztah): make output configurable instead of hardcoding to os.Stderr
95 _, _ = fmt.Fprintln(os.Stderr, fmt.Sprintf(unencryptedWarning, c.file.GetFilename()))
96 alreadyPrinted.Store(true)
97 }
98
99 return nil
100}
101
102// ConvertToHostname normalizes a registry URL which has http|https prepended
103// to just its hostname. It is used to match credentials, which may be either

Callers

nothing calls this directly

Calls 4

GetAuthConfigsMethod · 0.65
SaveMethod · 0.65
GetFilenameMethod · 0.65
StoreMethod · 0.65

Tested by

no test coverage detected