MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / LoadConfig

Function LoadConfig

cmd/cql-proxy/config/proxy.go:151–180  ·  view source on GitHub ↗

LoadConfig load the common covenantsql client config again for extra faucet config.

(listenAddr string, configPath string)

Source from the content-addressed store, hash-verified

149
150// LoadConfig load the common covenantsql client config again for extra faucet config.
151func LoadConfig(listenAddr string, configPath string) (config *Config, err error) {
152 var configBytes []byte
153 if configBytes, err = ioutil.ReadFile(configPath); err != nil {
154 log.WithError(err).Error("read config file failed")
155 return
156 }
157
158 configWrapper := &confWrapper{}
159 if err = yaml.Unmarshal(configBytes, configWrapper); err != nil {
160 log.WithError(err).Error("unmarshal config file failed")
161 return
162 }
163
164 if configWrapper.Proxy == nil {
165 err = ErrInvalidProxyConfig
166 log.WithError(err).Error("could not read proxy config")
167 return
168 }
169
170 config = configWrapper.Proxy
171
172 // override config
173 if listenAddr != "" {
174 config.ListenAddr = listenAddr
175 }
176
177 err = config.Validate()
178
179 return
180}

Callers 1

mainFunction · 0.92

Calls 4

WithErrorFunction · 0.92
ErrorMethod · 0.80
UnmarshalMethod · 0.80
ValidateMethod · 0.65

Tested by

no test coverage detected