From bec3d975e04ab1a86c360ba618be754fed11c0e0 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Thu, 15 Mar 2018 01:24:53 -0400 Subject: [PATCH] etcdmain: handle JSON "listen-metrics-urls" Signed-off-by: Gyuho Lee --- etcdmain/config.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/etcdmain/config.go b/etcdmain/config.go index d28a07c2e..afa54d9cd 100644 --- a/etcdmain/config.go +++ b/etcdmain/config.go @@ -20,12 +20,14 @@ import ( "flag" "fmt" "io/ioutil" + "net/url" "os" "runtime" "strings" "github.com/coreos/etcd/embed" "github.com/coreos/etcd/pkg/flags" + "github.com/coreos/etcd/pkg/types" "github.com/coreos/etcd/version" "github.com/ghodss/yaml" @@ -302,12 +304,22 @@ func (cfg *config) configFromFile(path string) error { if yerr := yaml.Unmarshal(b, &cfg.cp); yerr != nil { return yerr } + + if cfg.ec.ListenMetricsUrlsJSON != "" { + us, err := types.NewURLs(strings.Split(cfg.ec.ListenMetricsUrlsJSON, ",")) + if err != nil { + plog.Panicf("unexpected error setting up listen-metrics-urls: %v", err) + } + cfg.ec.ListenMetricsUrls = []url.URL(us) + } + if cfg.cp.FallbackJSON != "" { if err := cfg.cf.fallback.Set(cfg.cp.FallbackJSON); err != nil { plog.Panicf("unexpected error setting up discovery-fallback flag: %v", err) } cfg.cp.Fallback = cfg.cf.fallback.String() } + if cfg.cp.ProxyJSON != "" { if err := cfg.cf.proxy.Set(cfg.cp.ProxyJSON); err != nil { plog.Panicf("unexpected error setting up proxyFlag: %v", err)