MCPcopy Create free account
hub / github.com/amitsaha/gitbackup / loadConfigFile

Function loadConfigFile

config_file.go:146–163  ·  view source on GitHub ↗

loadConfigFile reads and parses the config file at the given path, or at the OS-specific default location if configPath is empty.

(configPath string)

Source from the content-addressed store, hash-verified

144// loadConfigFile reads and parses the config file at the given path,
145// or at the OS-specific default location if configPath is empty.
146func loadConfigFile(configPath string) (*fileConfig, error) {
147 path, err := resolveConfigPath(configPath)
148 if err != nil {
149 return nil, err
150 }
151
152 data, err := os.ReadFile(path)
153 if err != nil {
154 return nil, fmt.Errorf("error reading %s: %v", path, err)
155 }
156
157 var cfg fileConfig
158 err = yaml.Unmarshal(data, &cfg)
159 if err != nil {
160 return nil, fmt.Errorf("error parsing %s: %v", path, err)
161 }
162 return &cfg, nil
163}
164
165// handleValidateConfig reads the config file and validates its contents.
166// If configPath is empty, the OS-specific default location is used.

Callers 2

buildConfigFunction · 0.85
handleValidateConfigFunction · 0.85

Calls 1

resolveConfigPathFunction · 0.85

Tested by

no test coverage detected