config.Load() remove unneeded locks

These were added in b83bc67136, but
I'm not sure why I added these; they're likely not needed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2021-03-25 21:45:14 +01:00
parent d3c36a2a73
commit 09ddcffb2f
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 1 additions and 10 deletions

View File

@ -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 // TODO remove this temporary hack, which is used to warn about the deprecated ~/.dockercfg file
var ( var printLegacyFileWarning bool
mutex sync.RWMutex
printLegacyFileWarning bool
)
// Load reads the configuration files in the given directory, and sets up // Load reads the configuration files in the given directory, and sets up
// the auth config information and returns values. // the auth config information and returns values.
// FIXME: use the internal golang config parser // FIXME: use the internal golang config parser
func Load(configDir string) (*configfile.ConfigFile, error) { func Load(configDir string) (*configfile.ConfigFile, error) {
mutex.Lock()
printLegacyFileWarning = false printLegacyFileWarning = false
mutex.Unlock()
if configDir == "" { if configDir == "" {
configDir = Dir() 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 // Can't find latest config file so check for the old one
filename = filepath.Join(getHomeDir(), oldConfigfile) filename = filepath.Join(getHomeDir(), oldConfigfile)
if file, err := os.Open(filename); err == nil { if file, err := os.Open(filename); err == nil {
mutex.Lock()
printLegacyFileWarning = true printLegacyFileWarning = true
mutex.Unlock()
defer file.Close() defer file.Close()
if err := configFile.LegacyLoadFromReader(file); err != nil { if err := configFile.LegacyLoadFromReader(file); err != nil {
return configFile, errors.Wrap(err, filename) return configFile, errors.Wrap(err, filename)
@ -160,8 +153,6 @@ func LoadDefaultConfigFile(stderr io.Writer) *configfile.ConfigFile {
if err != nil { if err != nil {
fmt.Fprintf(stderr, "WARNING: Error loading config file: %v\n", err) fmt.Fprintf(stderr, "WARNING: Error loading config file: %v\n", err)
} }
mutex.RLock()
defer mutex.RUnlock()
if printLegacyFileWarning { 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") _, _ = fmt.Fprintln(stderr, "WARNING: Support for the legacy ~/.dockercfg configuration file and file-format is deprecated and will be removed in an upcoming release")
} }