X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=lib%2Fxdsconfig%2Fconfig.go;h=56a9cf9e2eac20bea07194f108405127e7844627;hb=459f46bc410c8641314d5f3eb39c871558b7d156;hp=9cff8620cb915bd4d161af8ed4f90b00a1cb705a;hpb=97ca1f277dc8b6973d6fa67add5593a9c395ce60;p=src%2Fxds%2Fxds-agent.git diff --git a/lib/xdsconfig/config.go b/lib/xdsconfig/config.go index 9cff862..56a9cf9 100644 --- a/lib/xdsconfig/config.go +++ b/lib/xdsconfig/config.go @@ -8,12 +8,14 @@ import ( "os" "github.com/Sirupsen/logrus" - "github.com/codegangsta/cli" + "github.com/urfave/cli" common "github.com/iotbzh/xds-common/golib" + uuid "github.com/satori/go.uuid" ) // Config parameters (json format) of /config command type Config struct { + AgentUID string Version string APIVersion string VersionGitTag string @@ -43,8 +45,12 @@ func Init(ctx *cli.Context, log *logrus.Logger) (*Config, error) { defaultWebAppDir := "${EXEPATH}/www" defaultSTHomeDir := "${HOME}/.xds/agent/syncthing-config" + // TODO: allocate uuid only the first time and save+reuse it later + uuid := uuid.NewV1().String() + // Define default configuration c := Config{ + AgentUID: uuid, Version: ctx.App.Metadata["version"].(string), APIVersion: DefaultAPIVersion, VersionGitTag: ctx.App.Metadata["git-tag"].(string), @@ -59,7 +65,6 @@ func Init(ctx *cli.Context, log *logrus.Logger) (*Config, error) { HTTPPort: "8800", WebAppDir: defaultWebAppDir, LogsDir: "/tmp/logs", - // SEB XDSAPIKey: "1234abcezam", ServersConf: []XDSServerConf{ XDSServerConf{ URL: "http://localhost:8000", @@ -73,6 +78,8 @@ func Init(ctx *cli.Context, log *logrus.Logger) (*Config, error) { Log: log, } + c.Log.Infoln("Agent UUID: ", uuid) + // config file settings overwrite default config err = readGlobalConfig(&c, c.Options.ConfigFile) if err != nil { @@ -107,6 +114,7 @@ func Init(ctx *cli.Context, log *logrus.Logger) (*Config, error) { return nil, fmt.Errorf("Cannot create logs dir: %v", err) } } + c.Log.Infoln("Logs file: ", c.Options.LogFile) c.Log.Infoln("Logs directory: ", c.FileConf.LogsDir)