Skip to content

Commit ec4b2a7

Browse files
committed
Environment variable for libnetwork address
Signed-off-by: Abhinandan Prativadi <abhi@docker.com> Signed-off-by: Madhu Venugopal <madhu@docker.com>
1 parent 58b376c commit ec4b2a7

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

config/config.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package config
22

33
import (
4+
"fmt"
5+
"os"
46
"strings"
57

68
"github.com/BurntSushi/toml"
@@ -69,7 +71,23 @@ func ParseConfig(tomlCfgFile string) (*Config, error) {
6971
if _, err := toml.DecodeFile(tomlCfgFile, cfg); err != nil {
7072
return nil, err
7173
}
74+
if cfg.Cluster.Address == "" {
75+
cfg.Cluster.Address = os.Getenv("DNET_ADDRESS")
76+
}
77+
if cfg.Cluster.Discovery == "" {
78+
cfg.Cluster.Discovery = os.Getenv("DNET_DISCOVERY")
79+
}
80+
fmt.Printf("cluster address=%s, discovery=%s \n", cfg.Cluster.Address, cfg.Cluster.Discovery)
81+
82+
if _, ok := cfg.Scopes[datastore.GlobalScope]; !ok {
83+
kvParts := strings.SplitN(cfg.Cluster.Discovery, "://", 2)
84+
if len(kvParts) == 2 {
85+
gCfg := datastore.ScopeClientCfg{Provider: kvParts[0], Address: kvParts[1]}
86+
cfg.Scopes[datastore.GlobalScope] = &datastore.ScopeCfg{gCfg}
87+
fmt.Printf("KVStore provider=%s, address=%s\n", kvParts[0], kvParts[1])
88+
}
7289

90+
}
7391
cfg.LoadDefaultScopes(cfg.Daemon.DataDir)
7492
return cfg, nil
7593
}

0 commit comments

Comments
 (0)