Use go module as dependency tool instead of glide
[src/xds/xds-server.git] / lib / xdsconfig / config.go
index ca5b5cb..ad3346a 100644 (file)
@@ -25,8 +25,8 @@ import (
        "path"
        "path/filepath"
 
-       common "gerrit.automotivelinux.org/gerrit/src/xds/xds-common.git/golib"
-       "gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xsapiv1"
+       common "gerrit.automotivelinux.org/gerrit/src/xds/xds-common.git"
+       "gerrit.automotivelinux.org/gerrit/src/xds/xds-server.git/lib/xsapiv1"
        "github.com/Sirupsen/logrus"
        "github.com/codegangsta/cli"
 )
@@ -53,12 +53,14 @@ type Options struct {
 
 // Config default values
 const (
-       DefaultAPIVersion    = "1"
-       DefaultPort          = "8000"
-       DefaultShareDir      = "projects"
-       DefaultSTHomeDir     = "syncthing-config"
-       DefaultSdkScriptsDir = "${EXEPATH}/sdks"
-       DefaultSdkDbUpdate   = "startup"
+       DefaultAPIVersion         = "1"
+       DefaultPort               = "8000"
+       DefaultShareDir           = "projects"
+       DefaultSTHomeDir          = "syncthing-config"
+       DefaultSdkScriptsDir      = "${EXEPATH}/sdks"
+       DefaultXdsUtilsScriptsDir = "${EXEPATH}/xds-utils"
+       DefaultSdkDbUpdate        = "startup"
+       DefaultXdsSrvUpdateTime   = "24h"
 )
 
 // Init loads the configuration on start-up
@@ -98,13 +100,15 @@ func Init(cliCtx *cli.Context, log *logrus.Logger) (*Config, error) {
                        NoFolderConfig: cliCtx.GlobalBool("no-folderconfig"),
                },
                FileConf: FileConfig{
-                       WebAppDir:     "webapp/dist",
-                       ShareRootDir:  dfltShareDir,
-                       SdkScriptsDir: DefaultSdkScriptsDir,
-                       SdkDbUpdate:   DefaultSdkDbUpdate,
-                       HTTPPort:      DefaultPort,
-                       SThgConf:      &SyncThingConf{Home: dfltSTHomeDir},
-                       LogsDir:       "",
+                       WebAppDir:          "www",
+                       ShareRootDir:       dfltShareDir,
+                       SdkScriptsDir:      DefaultSdkScriptsDir,
+                       XdsUtilsScriptsDir: DefaultXdsUtilsScriptsDir,
+                       SdkDbUpdate:        DefaultSdkDbUpdate,
+                       HTTPPort:           DefaultPort,
+                       SThgConf:           &SyncThingConf{Home: dfltSTHomeDir},
+                       LogsDir:            "",
+                       XdsSrvUpdateTime:   DefaultXdsSrvUpdateTime,
                },
                Log: log,
        }
@@ -174,3 +178,19 @@ func ConfigRootDir() string {
 
        return path.Join(root, "/.xds/server")
 }
+
+// WorkspaceRootDir return the path on server side where user xds-workspace dir is accessible
+func WorkspaceRootDir() string {
+       // May be overloaded by an env variable
+       if envVar, envDef := os.LookupEnv("XDS_SERVER_WORKSPACE_DIR"); envDef {
+               return envVar
+       }
+
+       home := "${HOME}"
+       if usr, err := user.Current(); err == nil {
+               home = usr.HomeDir
+       }
+
+       // Default value $HOME/xds-workspace
+       return path.Join(home, "xds-workspace")
+}