File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 66 "net/url"
77 "os"
88 "strings"
9+ "sync/atomic"
910
1011 "github.com/docker/cli/cli/config/types"
1112)
@@ -65,6 +66,10 @@ Configure a credential helper to remove this warning. See
6566https://docs.docker.com/go/credential-store/
6667`
6768
69+ // alreadyPrinted ensures that we only print the unencryptedWarning once per
70+ // CLI invocation (no need to warn the user multiple times per command).
71+ var alreadyPrinted atomic.Bool
72+
6873// Store saves the given credentials in the file store.
6974func (c * fileStore ) Store (authConfig types.AuthConfig ) error {
7075 authConfigs := c .file .GetAuthConfigs ()
@@ -73,11 +78,12 @@ func (c *fileStore) Store(authConfig types.AuthConfig) error {
7378 return err
7479 }
7580
76- if authConfig .Password != "" {
81+ if ! alreadyPrinted . Load () && authConfig .Password != "" {
7782 // Display a warning if we're storing the users password (not a token).
7883 //
7984 // FIXME(thaJeztah): make output configurable instead of hardcoding to os.Stderr
8085 _ , _ = fmt .Fprintln (os .Stderr , fmt .Sprintf (unencryptedWarning , c .file .GetFilename ()))
86+ alreadyPrinted .Store (true )
8187 }
8288
8389 return nil
You can’t perform that action at this time.
0 commit comments