File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package config
22
33import (
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}
You can’t perform that action at this time.
0 commit comments