MCPcopy
hub / github.com/cloudflare/cloudflared / readConfigFromPath

Function readConfigFromPath

config/manager.go:72–93  ·  view source on GitHub ↗
(configPath string, log *zerolog.Logger)

Source from the content-addressed store, hash-verified

70}
71
72func readConfigFromPath(configPath string, log *zerolog.Logger) (Root, error) {
73 if configPath == "" {
74 return Root{}, errors.New("unable to find config file")
75 }
76
77 file, err := os.Open(configPath)
78 if err != nil {
79 return Root{}, err
80 }
81 defer file.Close()
82
83 var config Root
84 if err := yaml.NewDecoder(file).Decode(&config); err != nil {
85 if err == io.EOF {
86 log.Error().Msgf("Configuration file %s was empty", configPath)
87 return Root{}, nil
88 }
89 return Root{}, errors.Wrap(err, "error parsing YAML in config file at "+configPath)
90 }
91
92 return config, nil
93}
94
95// File change notifications from the watcher
96

Callers

nothing calls this directly

Calls 3

CloseMethod · 0.65
DecodeMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected