summaryrefslogtreecommitdiffstats
path: root/lib/xdsconfig/fileconfig.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2018-07-18 15:41:51 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2018-07-18 17:52:00 +0200
commitb4ea2f3048518455b80262c16ebaa80d3cc7bba6 (patch)
tree73e014baac6a337610559ac5424181907128d3c6 /lib/xdsconfig/fileconfig.go
parentf63e5ae6aae50f62c82b3e8132659cb0c627c639 (diff)
Add XDS_SERVER_ROOT_CFG_DIR env var support
By default xds-server uses $HOME/.xds/server directory to save all config. This changes allows user to change this root directory by defining XDS_SERVER_ROOT_CFG_DIR environment variable. Change-Id: Iebde8dcf2d27b77671c7332bac04295d31659e24 Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/xdsconfig/fileconfig.go')
-rw-r--r--lib/xdsconfig/fileconfig.go13
1 files changed, 3 insertions, 10 deletions
diff --git a/lib/xdsconfig/fileconfig.go b/lib/xdsconfig/fileconfig.go
index 86f39b5..b786a24 100644
--- a/lib/xdsconfig/fileconfig.go
+++ b/lib/xdsconfig/fileconfig.go
@@ -28,9 +28,6 @@ import (
common "gerrit.automotivelinux.org/gerrit/src/xds/xds-common.git/golib"
)
-// ConfigDir Directory in user HOME directory where xds config will be saved
-var ConfigDir = path.Join(".xds", "server")
-
const (
// GlobalConfigFilename Global config filename
GlobalConfigFilename = "server-config.json"
@@ -74,8 +71,8 @@ func readGlobalConfig(c *Config, confFile string) error {
if confFile != "" {
searchIn = append(searchIn, confFile)
}
- if usr, err := user.Current(); err == nil {
- searchIn = append(searchIn, path.Join(usr.HomeDir, ConfigDir, GlobalConfigFilename))
+ if _, err := user.Current(); err == nil {
+ searchIn = append(searchIn, path.Join(ConfigRootDir(), GlobalConfigFilename))
}
searchIn = append(searchIn, "/etc/xds/server/server-config.json")
@@ -172,11 +169,7 @@ func readGlobalConfig(c *Config, confFile string) error {
}
func configFilenameGet(cfgFile string) (string, error) {
- usr, err := user.Current()
- if err != nil {
- return "", err
- }
- return path.Join(usr.HomeDir, ConfigDir, cfgFile), nil
+ return path.Join(ConfigRootDir(), cfgFile), nil
}
// FoldersConfigFilenameGet Return the FoldersConfig filename