MCPcopy Create free account
hub / github.com/dan-v/lambda-nat-proxy / FindConfigFile

Function FindConfigFile

internal/config/loader.go:116–141  ·  view source on GitHub ↗

FindConfigFile searches for a config file in XDG-compliant locations

()

Source from the content-addressed store, hash-verified

114
115// FindConfigFile searches for a config file in XDG-compliant locations
116func FindConfigFile() (string, error) {
117 searchPaths := []string{
118 "lambda-nat-proxy.yaml",
119 "lambda-nat-proxy.yml",
120 filepath.Join(xdg.ConfigHome, "lambda-nat-proxy", "lambda-nat-proxy.yaml"),
121 filepath.Join(xdg.ConfigHome, "lambda-nat-proxy", "lambda-nat-proxy.yml"),
122 "/etc/lambda-nat-proxy/lambda-nat-proxy.yaml",
123 "/etc/lambda-nat-proxy/lambda-nat-proxy.yml",
124 }
125
126 // Also check XDG config dirs
127 for _, dir := range xdg.ConfigDirs {
128 searchPaths = append(searchPaths,
129 filepath.Join(dir, "lambda-nat-proxy", "lambda-nat-proxy.yaml"),
130 filepath.Join(dir, "lambda-nat-proxy", "lambda-nat-proxy.yml"),
131 )
132 }
133
134 for _, path := range searchPaths {
135 if _, err := os.Stat(path); err == nil {
136 return path, nil
137 }
138 }
139
140 return "", fmt.Errorf("no config file found in standard locations")
141}
142
143// GetDefaultConfigPath returns the default path for creating a new config file
144func GetDefaultConfigPath() string {

Callers 1

getConfigSourceFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected