X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=lib%2Fxdsconfig%2Fconfig.go;h=ef94f0ad8848edd0847ea7e2a3663e2afb4c117c;hb=005e0eb072418456055783491f907fc08cb42fd7;hp=9cff8620cb915bd4d161af8ed4f90b00a1cb705a;hpb=97ca1f277dc8b6973d6fa67add5593a9c395ce60;p=src%2Fxds%2Fxds-agent.git diff --git a/lib/xdsconfig/config.go b/lib/xdsconfig/config.go index 9cff862..ef94f0a 100644 --- a/lib/xdsconfig/config.go +++ b/lib/xdsconfig/config.go @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2017-2018 "IoT.bzh" + * Author Sebastien Douheret + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package xdsconfig import ( @@ -7,13 +24,15 @@ import ( "os" + common "gerrit.automotivelinux.org/gerrit/src/xds/xds-common.git/golib" "github.com/Sirupsen/logrus" - "github.com/codegangsta/cli" - common "github.com/iotbzh/xds-common/golib" + uuid "github.com/satori/go.uuid" + "github.com/urfave/cli" ) // Config parameters (json format) of /config command type Config struct { + AgentUID string Version string APIVersion string VersionGitTag string @@ -43,8 +62,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 +82,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", @@ -69,10 +91,18 @@ func Init(ctx *cli.Context, log *logrus.Logger) (*Config, error) { SThgConf: &SyncThingConf{ Home: defaultSTHomeDir, }, + ProfileConf: ProfileConfT{ + XDSBinder: XDSBinderConf{ + URL: "http://localhost:8810", + ConnRetry: 10, + }, + }, }, 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 +137,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)