Skip to content
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

Merged
merged 1 commit into from
May 30, 2017
Merged

Logs & errors review #1673

merged 1 commit into from
May 30, 2017

Conversation

ldez
Copy link
Contributor

@ldez ldez commented May 26, 2017

Description

  • log & error: remove format if not necessary, add if necessary.
  • add constants for k8s annotations.
  • fix typos

Copy link
Contributor

@timoreimann timoreimann left a 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.

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Label -> label

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Label -> label

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad -> bad

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to known! 👍

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad -> bad

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad -> bad

@@ -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)
Copy link
Contributor

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.

}

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)
Copy link
Contributor

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.

}

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)
Copy link
Contributor

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.

@@ -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)
Copy link
Contributor

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.

}

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)
Copy link
Contributor

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.

@ldez ldez added this to the 1.4 milestone May 29, 2017
@ldez ldez force-pushed the refactor/logs-review branch 2 times, most recently from 48baf52 to f12622d Compare May 30, 2017 18:04
Copy link
Member

@emilevauge emilevauge left a 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

@ldez
Copy link
Contributor Author

ldez commented May 30, 2017

ping @timoreimann 😉

- log & error: remove format if not necessary, add if necessary.
- add constants for k8s annotations.
- fix typos
Copy link
Contributor

@timoreimann timoreimann left a 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. 😺 👍

@ldez ldez merged commit cbccdd5 into traefik:master May 30, 2017
@ldez ldez deleted the refactor/logs-review branch May 30, 2017 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/logs kind/enhancement a new or improved feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants