Added target and terminal support.
[src/xds/xds-server.git] / lib / xdsconfig / fileconfig.go
index 8e77de7..86f39b5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 "IoT.bzh"
+ * Copyright (C) 2017-2018 "IoT.bzh"
  * Author Sebastien Douheret <sebastien@iot.bzh>
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,7 +25,7 @@ import (
        "path/filepath"
        "strings"
 
-       common "github.com/iotbzh/xds-common/golib"
+       common "gerrit.automotivelinux.org/gerrit/src/xds/xds-common.git/golib"
 )
 
 // ConfigDir Directory in user HOME directory where xds config will be saved
@@ -38,6 +38,8 @@ const (
        ServerDataFilename = "server-data.xml"
        // FoldersConfigFilename Folders config filename
        FoldersConfigFilename = "server-config_folders.xml"
+       // TargetsConfigFilename Targets config filename
+       TargetsConfigFilename = "server-config_targets.xml"
 )
 
 // SyncThingConf definition
@@ -51,12 +53,13 @@ type SyncThingConf struct {
 
 // FileConfig is the JSON structure of xds-server config file (server-config.json)
 type FileConfig struct {
-       WebAppDir    string         `json:"webAppDir"`
-       ShareRootDir string         `json:"shareRootDir"`
-       SdkRootDir   string         `json:"sdkRootDir"`
-       HTTPPort     string         `json:"httpPort"`
-       SThgConf     *SyncThingConf `json:"syncthing"`
-       LogsDir      string         `json:"logsDir"`
+       WebAppDir     string         `json:"webAppDir"`
+       ShareRootDir  string         `json:"shareRootDir"`
+       SdkScriptsDir string         `json:"sdkScriptsDir"`
+       SdkDbUpdate   string         `json:"sdkDbUpdate"`
+       HTTPPort      string         `json:"httpPort"`
+       SThgConf      *SyncThingConf `json:"syncthing"`
+       LogsDir       string         `json:"logsDir"`
 }
 
 // readGlobalConfig reads configuration from a config file.
@@ -117,7 +120,7 @@ func readGlobalConfig(c *Config, confFile string) error {
        vars := []*string{
                &fCfg.WebAppDir,
                &fCfg.ShareRootDir,
-               &fCfg.SdkRootDir,
+               &fCfg.SdkScriptsDir,
                &fCfg.LogsDir}
        if fCfg.SThgConf != nil {
                vars = append(vars, &fCfg.SThgConf.Home, &fCfg.SThgConf.BinDir)
@@ -136,8 +139,11 @@ func readGlobalConfig(c *Config, confFile string) error {
        if fCfg.ShareRootDir == "" {
                fCfg.ShareRootDir = c.FileConf.ShareRootDir
        }
-       if fCfg.SdkRootDir == "" {
-               fCfg.SdkRootDir = c.FileConf.SdkRootDir
+       if fCfg.SdkScriptsDir == "" {
+               fCfg.SdkScriptsDir = c.FileConf.SdkScriptsDir
+       }
+       if fCfg.SdkDbUpdate == "" {
+               fCfg.SdkDbUpdate = c.FileConf.SdkDbUpdate
        }
        if fCfg.HTTPPort == "" {
                fCfg.HTTPPort = c.FileConf.HTTPPort
@@ -173,12 +179,17 @@ func configFilenameGet(cfgFile string) (string, error) {
        return path.Join(usr.HomeDir, ConfigDir, cfgFile), nil
 }
 
-// FoldersConfigFilenameGet
+// FoldersConfigFilenameGet Return the FoldersConfig filename
 func FoldersConfigFilenameGet() (string, error) {
        return configFilenameGet(FoldersConfigFilename)
 }
 
-// ServerDataFilenameGet
+// TargetsConfigFilenameGet Return the TargetsConfig filename
+func TargetsConfigFilenameGet() (string, error) {
+       return configFilenameGet(TargetsConfigFilename)
+}
+
+// ServerDataFilenameGet Return the ServerData filename
 func ServerDataFilenameGet() (string, error) {
        return configFilenameGet(ServerDataFilename)
 }