refactor: Logs & errors review.
- log & error: remove format if not necessary, add if necessary. - add constants for k8s annotations. - fix typos
This commit is contained in:
parent
994e135368
commit
cbccdd51c5
26 changed files with 125 additions and 128 deletions
|
@ -2,7 +2,7 @@ package docker
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"net"
|
||||
"net/http"
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
func getLabels(container dockerData, labels []string) (map[string]string, error) {
|
||||
|
@ -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)
|
||||
continue
|
||||
}
|
||||
foundLabels[label] = foundLabel
|
||||
|
|
|
@ -469,7 +469,7 @@ func TestDockerGetLabel(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
container: containerJSON(),
|
||||
expected: "Label not found:",
|
||||
expected: "label not found:",
|
||||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
|
@ -507,7 +507,7 @@ func TestDockerGetLabels(t *testing.T) {
|
|||
{
|
||||
container: containerJSON(),
|
||||
expectedLabels: map[string]string{},
|
||||
expectedError: "Label not found:",
|
||||
expectedError: "label not found:",
|
||||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
|
@ -516,7 +516,7 @@ func TestDockerGetLabels(t *testing.T) {
|
|||
expectedLabels: map[string]string{
|
||||
"foo": "fooz",
|
||||
},
|
||||
expectedError: "Label not found: bar",
|
||||
expectedError: "label not found: bar",
|
||||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
|
|
|
@ -415,7 +415,7 @@ func TestSwarmGetLabel(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
service: swarmService(),
|
||||
expected: "Label not found:",
|
||||
expected: "label not found:",
|
||||
networks: map[string]*docker.NetworkResource{},
|
||||
},
|
||||
{
|
||||
|
@ -439,7 +439,7 @@ func TestSwarmGetLabel(t *testing.T) {
|
|||
}
|
||||
} else {
|
||||
if label != "bar" {
|
||||
t.Errorf("expected label 'bar', got %s", label)
|
||||
t.Errorf("expected label 'bar', got '%s'", label)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -456,7 +456,7 @@ func TestSwarmGetLabels(t *testing.T) {
|
|||
{
|
||||
service: swarmService(),
|
||||
expectedLabels: map[string]string{},
|
||||
expectedError: "Label not found:",
|
||||
expectedError: "label not found:",
|
||||
networks: map[string]*docker.NetworkResource{},
|
||||
},
|
||||
{
|
||||
|
@ -466,7 +466,7 @@ func TestSwarmGetLabels(t *testing.T) {
|
|||
expectedLabels: map[string]string{
|
||||
"foo": "fooz",
|
||||
},
|
||||
expectedError: "Label not found: bar",
|
||||
expectedError: "label not found: bar",
|
||||
networks: map[string]*docker.NetworkResource{},
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue