+ // Early and manual processing of --config option in order to set XDS_xxx
+ // variables before parsing of option by app cli
+ confFile := os.Getenv("XDS_CONFIG")
+ for idx, a := range os.Args[1:] {
+ if a == "-c" || a == "--config" || a == "-config" {
+ confFile = os.Args[idx+2]
+ break
+ }
+ }
+
+ // Load config file if requested
+ if confFile != "" {
+ earlyPrintf("confFile detected: %v", confFile)
+ confFile, err := common.ResolveEnvVar(confFile)
+ if err != nil {
+ exitError(1, "Error while resolving confFile: %v", err)
+ }
+ earlyPrintf("Resolved confFile: %v", confFile)
+ if !common.Exists(confFile) {
+ exitError(1, "Error env config file not found")
+ }
+ // Load config file variables that will overwrite env variables
+ err = godotenv.Overload(confFile)
+ if err != nil {
+ exitError(1, "Error loading env config file "+confFile)
+ }
+
+ // Keep confFile settings in a map
+ EnvConfFileMap, err = godotenv.Read(confFile)
+ if err != nil {
+ exitError(1, "Error reading env config file "+confFile)
+ }
+ earlyPrintf("EnvConfFileMap: %v", EnvConfFileMap)
+ }
+