help people figure out why their syslog url is wrong more better (#1242)

closes #1240
This commit is contained in:
Reed Allman
2018-09-26 11:56:14 -07:00
committed by GitHub
parent 1855ebf2ce
commit 911c7d993e
2 changed files with 5 additions and 6 deletions

View File

@@ -86,17 +86,16 @@ func (a *App) Validate() error {
if a.SyslogURL != nil && *a.SyslogURL != "" {
url, err := url.Parse(strings.TrimSpace(*a.SyslogURL))
fail := err != nil
if !fail {
if err == nil {
// See: https://docs.docker.com/config/containers/logging/syslog/#options
switch url.Scheme {
case "udp", "tcp", "unix", "unixgram", "tcp+tls":
default:
fail = true
err = fmt.Errorf("invalid scheme, only [tcp, udp, unix, unixgram, tcp+tls] are supported")
}
}
if fail {
return ErrInvalidSyslog(fmt.Sprintf(`invalid syslog url: "%v"`, *a.SyslogURL))
if err != nil { // not else if for a reason...
return ErrInvalidSyslog(fmt.Sprintf(`invalid syslog url: "%v" %v`, *a.SyslogURL, err))
}
}
return nil