From b7230b2897898831200874dde115c4e3a368b1ae Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 11 Jan 2014 10:41:36 -0800 Subject: [PATCH] client: add CAMLI_DEFAULT_SERVER env option for selecting default server For demos, when we want to show using camput/camget but select the devcam server instead of our production servers. Change-Id: Ie2adfd4f80df3119a705b51bb9736c3b66612d1c --- doc/environment-vars.txt | 5 +++++ pkg/client/config.go | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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) } }