aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/xdsconfig/config.go16
-rw-r--r--lib/xdsserver/sdks.go4
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/xdsconfig/config.go b/lib/xdsconfig/config.go
index ca5b5cb..4ba97ef 100644
--- a/lib/xdsconfig/config.go
+++ b/lib/xdsconfig/config.go
@@ -174,3 +174,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")
+}
diff --git a/lib/xdsserver/sdks.go b/lib/xdsserver/sdks.go
index ee6a269..47d48d5 100644
--- a/lib/xdsserver/sdks.go
+++ b/lib/xdsserver/sdks.go
@@ -25,6 +25,7 @@ import (
"sync"
common "gerrit.automotivelinux.org/gerrit/src/xds/xds-common.git/golib"
+ "gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xdsconfig"
"gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xsapiv1"
)
@@ -349,7 +350,8 @@ func (s *SDKs) Install(id, filepath string, force bool, timeout int, args []stri
} else if filepath != "" {
// FIXME support any location and also sharing either by pathmap or Syncthing
- baseDir := "${HOME}/xds-workspace/sdks"
+
+ baseDir := path.Join(xdsconfig.WorkspaceRootDir(), "sdks")
sdkFilename, _ = common.ResolveEnvVar(path.Join(baseDir, path.Base(filepath)))
if !common.Exists(sdkFilename) {
return nil, fmt.Errorf("SDK file not accessible, must be in %s", baseDir)