You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by de...@apache.org on 2018/07/23 19:44:33 UTC
[trafficcontrol] 01/02: properly handle missing listen field in
cdn.conf
This is an automated email from the ASF dual-hosted git repository.
dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 03b953d1f20999fec79715190c9c0f119a958c29
Author: Dylan Volz <Dy...@comcast.com>
AuthorDate: Thu Jul 12 12:39:31 2018 -0600
properly handle missing listen field in cdn.conf
---
traffic_ops/traffic_ops_golang/config/config.go | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/traffic_ops/traffic_ops_golang/config/config.go b/traffic_ops/traffic_ops_golang/config/config.go
index 8b2152d..8257981 100644
--- a/traffic_ops/traffic_ops_golang/config/config.go
+++ b/traffic_ops/traffic_ops_golang/config/config.go
@@ -166,7 +166,7 @@ func LoadConfig(cdnConfPath string, dbConfPath string, riakConfPath string, appV
}
cfg, err = ParseConfig(cfg)
if err != nil {
- return Config{}, []error{fmt.Errorf("parsing config '%s': %v", dbConfPath, err)}, BlockStartup
+ return Config{}, []error{fmt.Errorf("parsing config '%s': %v", cdnConfPath, err)}, BlockStartup
}
if riakConfPath != "" {
@@ -256,15 +256,19 @@ func ParseConfig(cfg Config) (Config, error) {
invalidTOURLStr := ""
var err error
- listen := cfg.Listen[0]
- if cfg.URL, err = url.Parse(listen); err != nil {
- invalidTOURLStr = fmt.Sprintf("invalid Traffic Ops URL '%s': %v", listen, err)
- }
- cfg.KeyPath = cfg.GetKeyPath()
- cfg.CertPath = cfg.GetCertPath()
+ if len(cfg.Listen) < 1 {
+ missings += "listen, "
+ } else {
+ listen := cfg.Listen[0]
+ if cfg.URL, err = url.Parse(listen); err != nil {
+ invalidTOURLStr = fmt.Sprintf("invalid Traffic Ops URL '%s': %v", listen, err)
+ }
+ cfg.KeyPath = cfg.GetKeyPath()
+ cfg.CertPath = cfg.GetCertPath()
- newURL := url.URL{Scheme: cfg.URL.Scheme, Host: cfg.URL.Host, Path: cfg.URL.Path}
- cfg.URL = &newURL
+ newURL := url.URL{Scheme: cfg.URL.Scheme, Host: cfg.URL.Host, Path: cfg.URL.Path}
+ cfg.URL = &newURL
+ }
if len(missings) > 0 {
missings = "missing fields: " + missings[:len(missings)-2] // strip final `, `