mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
daemon/logger/gelf: remove uses of pkg/urlutil.IsTransportURL()
pkg/urlutil (despite its poorly chosen name) is not really intended as a generic utility to handle URLs, and should only be used by the builder to handle (remote) build contexts. This patch: - removes a redundant use of urlutil.IsTransportURL(); code further below already checked if the given scheme (protocol) was supported. - renames some variables that collided with imported packages. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
c6872980bb
commit
2e831c76c2
2 changed files with 8 additions and 14 deletions
|
@ -14,7 +14,6 @@ import (
|
|||
"github.com/Graylog2/go-gelf/gelf"
|
||||
"github.com/docker/docker/daemon/logger"
|
||||
"github.com/docker/docker/daemon/logger/loggerutils"
|
||||
"github.com/docker/docker/pkg/urlutil"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
@ -251,23 +250,18 @@ func parseAddress(address string) (*url.URL, error) {
|
|||
if address == "" {
|
||||
return nil, fmt.Errorf("gelf-address is a required parameter")
|
||||
}
|
||||
if !urlutil.IsTransportURL(address) {
|
||||
return nil, fmt.Errorf("gelf-address should be in form proto://address, got %v", address)
|
||||
}
|
||||
url, err := url.Parse(address)
|
||||
addr, err := url.Parse(address)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// we support only udp
|
||||
if url.Scheme != "udp" && url.Scheme != "tcp" {
|
||||
if addr.Scheme != "udp" && addr.Scheme != "tcp" {
|
||||
return nil, fmt.Errorf("gelf: endpoint needs to be TCP or UDP")
|
||||
}
|
||||
|
||||
// get host and port
|
||||
if _, _, err = net.SplitHostPort(url.Host); err != nil {
|
||||
if _, _, err = net.SplitHostPort(addr.Host); err != nil {
|
||||
return nil, fmt.Errorf("gelf: please provide gelf-address as proto://host:port")
|
||||
}
|
||||
|
||||
return url, nil
|
||||
return addr, nil
|
||||
}
|
||||
|
|
|
@ -223,12 +223,12 @@ func TestNewTCP(t *testing.T) {
|
|||
ContainerID: "12345678901234567890",
|
||||
}
|
||||
|
||||
logger, err := New(info)
|
||||
gelfLogger, err := New(info)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = logger.Close()
|
||||
err = gelfLogger.Close()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -250,12 +250,12 @@ func TestNewUDP(t *testing.T) {
|
|||
ContainerID: "12345678901234567890",
|
||||
}
|
||||
|
||||
logger, err := New(info)
|
||||
gelfLogger, err := New(info)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = logger.Close()
|
||||
err = gelfLogger.Close()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue