diff --git a/doc/environment-vars.txt b/doc/environment-vars.txt index 14936a596..579869a3c 100644 --- a/doc/environment-vars.txt +++ b/doc/environment-vars.txt @@ -45,6 +45,11 @@ CAMLI_DEBUG_CONFIG (bool): CAMLI_DEBUG_UPLOADS (bool): Used by pkg/client to enable additional logging. +CAMLI_DEFAULT_SERVER (string): + The server alias to use by default. The string is the server's alias key + in the client-config.json "servers" object. If set, the CAMLI_DEFAULT_SERVER + takes precedence over the "default" bool in client-config.json. + CAMLI_DEV_CAMLI_ROOT (string): If set, the base directory of Camlistore when in dev mode. Used by pkg/server for finding static assests (js, css, html). diff --git a/pkg/client/config.go b/pkg/client/config.go index 808d292b0..b53ab8997 100644 --- a/pkg/client/config.go +++ b/pkg/client/config.go @@ -257,8 +257,9 @@ func serverOrDie() string { func defaultServer() string { configOnce.Do(parseConfig) - for _, serverConf := range config.Servers { - if serverConf.IsDefault { + wantAlias := os.Getenv("CAMLI_DEFAULT_SERVER") + for alias, serverConf := range config.Servers { + if (wantAlias != "" && wantAlias == alias) || (wantAlias == "" && serverConf.IsDefault) { return cleanServer(serverConf.Server) } }