-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logs & errors review #1673
Logs & errors review #1673
Conversation
318294b
to
29042b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My OCD ❤️ s this PR. :-)
A few minor remarks, basically just repetitions of two classes of comments.
provider/docker/docker.go
Outdated
@@ -705,7 +705,7 @@ func getLabel(container dockerData, label string) (string, error) { | |||
return value, nil | |||
} | |||
} | |||
return "", errors.New("Label not found:" + label) | |||
return "", fmt.Errorf("Label not found: %s", label) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label -> label
provider/docker/docker.go
Outdated
@@ -715,7 +715,7 @@ func getLabels(container dockerData, labels []string) (map[string]string, error) | |||
foundLabel, err := getLabel(container, label) | |||
// Error out only if one of them is defined. | |||
if err != nil { | |||
globalErr = errors.New("Label not found: " + label) | |||
globalErr = fmt.Errorf("Label not found: %s", label) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label -> label
server/configuration.go
Outdated
@@ -88,7 +88,7 @@ func (dep *DefaultEntryPoints) String() string { | |||
func (dep *DefaultEntryPoints) Set(value string) error { | |||
entrypoints := strings.Split(value, ",") | |||
if len(entrypoints) == 0 { | |||
return errors.New("Bad DefaultEntryPoints format: " + value) | |||
return fmt.Errorf("Bad DefaultEntryPoints format: %s", value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad -> bad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why put the first letter in lower case? For me, a sentence begins with an uppercase letter. If it's for consistency, I can change the others too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to known! 👍
server/configuration.go
Outdated
@@ -127,7 +127,7 @@ func (ep *EntryPoints) Set(value string) error { | |||
regex := regexp.MustCompile("(?:Name:(?P<Name>\\S*))\\s*(?:Address:(?P<Address>\\S*))?\\s*(?:TLS:(?P<TLS>\\S*))?\\s*((?P<TLSACME>TLS))?\\s*(?:CA:(?P<CA>\\S*))?\\s*(?:Redirect.EntryPoint:(?P<RedirectEntryPoint>\\S*))?\\s*(?:Redirect.Regex:(?P<RedirectRegex>\\S*))?\\s*(?:Redirect.Replacement:(?P<RedirectReplacement>\\S*))?\\s*(?:Compress:(?P<Compress>\\S*))?") | |||
match := regex.FindAllStringSubmatch(value, -1) | |||
if match == nil { | |||
return errors.New("Bad EntryPoints format: " + value) | |||
return fmt.Errorf("Bad EntryPoints format: %s", value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad -> bad
server/configuration.go
Outdated
@@ -314,7 +314,7 @@ func (certs *Certificates) Set(value string) error { | |||
for _, certificate := range certificates { | |||
files := strings.Split(certificate, ",") | |||
if len(files) != 2 { | |||
return errors.New("Bad certificates format: " + value) | |||
return fmt.Errorf("Bad certificates format: %s", value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad -> bad
server/rules_test.go
Outdated
@@ -41,23 +40,21 @@ func TestParseTwoRules(t *testing.T) { | |||
routeResult, err := rules.Parse(expression) | |||
|
|||
if err != nil { | |||
t.Fatal("Error while building route for Host:foo.bar;Path:/FOObar") | |||
t.Fatal("Error while building route for Host:foo.bar;Path:/FOObar", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to use t.Fatalf
.
server/rules_test.go
Outdated
} | ||
|
||
request, err := http.NewRequest("GET", "http://foo.bar/foobar", nil) | ||
routeMatch := routeResult.Match(request, &mux.RouteMatch{Route: routeResult}) | ||
|
||
if routeMatch == true { | ||
t.Log(err) | ||
t.Fatal("Rule Host:foo.bar;Path:/FOObar don't match") | ||
t.Fatal("Rule Host:foo.bar;Path:/FOObar don't match", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to use t.Fatalf
.
server/rules_test.go
Outdated
} | ||
|
||
request, err = http.NewRequest("GET", "http://foo.bar/FOObar", nil) | ||
routeMatch = routeResult.Match(request, &mux.RouteMatch{Route: routeResult}) | ||
|
||
if routeMatch == false { | ||
t.Log(err) | ||
t.Fatal("Rule Host:foo.bar;Path:/FOObar don't match") | ||
t.Fatal("Rule Host:foo.bar;Path:/FOObar don't match", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to use t.Fatalf
.
server/rules_test.go
Outdated
@@ -92,48 +89,48 @@ func TestPriorites(t *testing.T) { | |||
rules := &Rules{route: &serverRoute{route: router.NewRoute()}} | |||
routeFoo, err := rules.Parse("PathPrefix:/foo") | |||
if err != nil { | |||
t.Fatal("Error while building route for PathPrefix:/foo") | |||
t.Fatal("Error while building route for PathPrefix:/foo", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to use t.Fatalf
.
server/rules_test.go
Outdated
} | ||
|
||
multipleRules := &Rules{route: &serverRoute{route: router.NewRoute()}} | ||
routeFoobar, err := multipleRules.Parse("PathPrefix:/foobar") | ||
if err != nil { | ||
t.Fatal("Error while building route for PathPrefix:/foobar") | ||
t.Fatal("Error while building route for PathPrefix:/foobar", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to use t.Fatalf
.
fda6eb2
to
d54ffbc
Compare
48baf52
to
f12622d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @ldez !
LGTM
ping @timoreimann 😉 |
- log & error: remove format if not necessary, add if necessary. - add constants for k8s annotations. - fix typos
f12622d
to
ad531db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, @ldez -- one less consistency problem in the world to think about. 😺 👍
Description