MCPcopy Index your code
hub / github.com/docker/cli / load

Function load

cli/config/config.go:133–153  ·  view source on GitHub ↗
(configDir string)

Source from the content-addressed store, hash-verified

131}
132
133func load(configDir string) (*configfile.ConfigFile, error) {
134 filename := filepath.Join(configDir, ConfigFileName)
135 configFile := configfile.New(filename)
136
137 file, err := os.Open(filename)
138 if err != nil {
139 if os.IsNotExist(err) {
140 // It is OK for no configuration file to be present, in which
141 // case we return a default struct.
142 return configFile, nil
143 }
144 // Any other error happening when failing to read the file must be returned.
145 return configFile, fmt.Errorf("loading config file: %w", err)
146 }
147 defer func() { _ = file.Close() }()
148 err = configFile.LoadFromReader(file)
149 if err != nil {
150 err = fmt.Errorf("parsing config file (%s): %w", filename, err)
151 }
152 return configFile, err
153}
154
155// LoadDefaultConfigFile attempts to load the default config file and returns
156// a reference to the ConfigFile struct. If none is found or when failing to load

Callers 2

LoadFunction · 0.85
LoadDefaultConfigFileFunction · 0.85

Calls 2

LoadFromReaderMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…