1. from command line option: `--config myConfig.json`
1. `$HOME/.xds/agent/agent-config.json` file
-1. `<current dir>/agent-config.json` file
+1. `/etc/xds-agent/agent-config.json` file
1. `<xds-agent executable dir>/agent-config.json` file
Supported fields in configuration file are (all fields are optional and example
if usr, err := user.Current(); err == nil {
searchIn = append(searchIn, path.Join(usr.HomeDir, ".xds", "agent", "agent-config.json"))
}
- cwd, err := os.Getwd()
- if err == nil {
- searchIn = append(searchIn, path.Join(cwd, "agent-config.json"))
- }
- exePath, err := filepath.Abs(filepath.Dir(os.Args[0]))
+
+ searchIn = append(searchIn, "/etc/xds-agent/agent-config.json")
+
+ exePath := os.Args[0]
+ ee, _ := os.Executable()
+ exeAbsPath, err := filepath.Abs(ee)
if err == nil {
- searchIn = append(searchIn, path.Join(exePath, "agent-config.json"))
+ exePath, err = filepath.EvalSymlinks(exeAbsPath)
+ if err == nil {
+ exePath = filepath.Dir(ee)
+ } else {
+ exePath = filepath.Dir(exeAbsPath)
+ }
}
+ searchIn = append(searchIn, path.Join(exePath, "agent-config.json"))
var cFile *string
for _, p := range searchIn {