Skip to content

Commit

Permalink
config.Load() remove unneeded locks
Browse files Browse the repository at this point in the history
These were added in b83bc67, but
I'm not sure why I added these; they're likely not needed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 09ddcff)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Apr 1, 2021
1 parent 4571d90 commit 4c3b87d
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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")
}
Expand Down

0 comments on commit 4c3b87d

Please sign in to comment.