From 2bb97a6c2b5cb42b3c5166638141abb985aaddf9 Mon Sep 17 00:00:00 2001 From: Laura Brehm Date: Mon, 5 Aug 2024 12:16:02 +0100 Subject: [PATCH] filestore: don't print warning multiple times Signed-off-by: Laura Brehm --- cli/config/credentials/file_store.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cli/config/credentials/file_store.go b/cli/config/credentials/file_store.go index 6a093428fd03..6de42a1413b0 100644 --- a/cli/config/credentials/file_store.go +++ b/cli/config/credentials/file_store.go @@ -65,6 +65,8 @@ Configure a credential helper to remove this warning. See https://docs.docker.com/go/credential-store/ ` +var alreadyPrinted bool + // Store saves the given credentials in the file store. func (c *fileStore) Store(authConfig types.AuthConfig) error { authConfigs := c.file.GetAuthConfigs() @@ -73,11 +75,12 @@ func (c *fileStore) Store(authConfig types.AuthConfig) error { return err } - if authConfig.Password != "" { + if !alreadyPrinted && authConfig.Password != "" { // Display a warning if we're storing the users password (not a token). // // FIXME(thaJeztah): make output configurable instead of hardcoding to os.Stderr _, _ = fmt.Fprintln(os.Stderr, fmt.Sprintf(unencryptedWarning, c.file.GetFilename())) + alreadyPrinted = true } return nil