From 4c3b87d92249114fdaa651b1dbd37bb18699e869 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 25 Mar 2021 21:45:14 +0100 Subject: [PATCH] config.Load() remove unneeded locks These were added in b83bc67136e1edce2bdc225863af83d45d5472c9, but I'm not sure why I added these; they're likely not needed. Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 09ddcffb2f5d8455744e46e91a502f7fbac9e882) Signed-off-by: Sebastiaan van Stijn --- cli/config/config.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/cli/config/config.go b/cli/config/config.go index 3f208f9c88..93275f3d98 100644 --- a/cli/config/config.go +++ b/cli/config/config.go @@ -105,18 +105,13 @@ func LoadFromReader(configData io.Reader) (*configfile.ConfigFile, error) { } // TODO remove this temporary hack, which is used to warn about the deprecated ~/.dockercfg file -var ( - mutex sync.RWMutex - printLegacyFileWarning bool -) +var printLegacyFileWarning bool // Load reads the configuration files in the given directory, and sets up // the auth config information and returns values. // FIXME: use the internal golang config parser func Load(configDir string) (*configfile.ConfigFile, error) { - mutex.Lock() printLegacyFileWarning = false - mutex.Unlock() if configDir == "" { configDir = Dir() @@ -142,9 +137,7 @@ func Load(configDir string) (*configfile.ConfigFile, error) { // Can't find latest config file so check for the old one filename = filepath.Join(getHomeDir(), oldConfigfile) if file, err := os.Open(filename); err == nil { - mutex.Lock() printLegacyFileWarning = true - mutex.Unlock() defer file.Close() if err := configFile.LegacyLoadFromReader(file); err != nil { return configFile, errors.Wrap(err, filename) @@ -160,8 +153,6 @@ func LoadDefaultConfigFile(stderr io.Writer) *configfile.ConfigFile { if err != nil { fmt.Fprintf(stderr, "WARNING: Error loading config file: %v\n", err) } - mutex.RLock() - defer mutex.RUnlock() if printLegacyFileWarning { _, _ = fmt.Fprintln(stderr, "WARNING: Support for the legacy ~/.dockercfg configuration file and file-format is deprecated and will be removed in an upcoming release") }