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

Function FindDefaultConfigPath

config/configuration.go:105–119  ·  view source on GitHub ↗

FindDefaultConfigPath returns the first path that contains a config file. If none of the combination of DefaultConfigSearchDirectories() and DefaultConfigFiles contains a config file, return empty string.

()

Source from the content-addressed store, hash-verified

103// If none of the combination of DefaultConfigSearchDirectories() and DefaultConfigFiles
104// contains a config file, return empty string.
105func FindDefaultConfigPath() string {
106 for _, configDir := range DefaultConfigSearchDirectories() {
107 for _, configFile := range DefaultConfigFiles {
108 dirPath, err := homedir.Expand(configDir)
109 if err != nil {
110 continue
111 }
112 path := filepath.Join(dirPath, configFile)
113 if ok, _ := FileExists(path); ok {
114 return path
115 }
116 }
117 }
118 return ""
119}
120
121// FindOrCreateConfigPath returns the first path that contains a config file
122// or creates one in the primary default path if it doesn't exist

Callers 2

FindOrCreateConfigPathFunction · 0.85

Calls 2

FileExistsFunction · 0.85

Tested by

no test coverage detected