diff --git a/opts/envfile_test.go b/opts/envfile_test.go index bda9dcb6e7..f875707a5e 100644 --- a/opts/envfile_test.go +++ b/opts/envfile_test.go @@ -100,7 +100,7 @@ func TestParseEnvFileBadlyFormattedFile(t *testing.T) { if _, ok := err.(ErrBadKey); !ok { t.Fatalf("Expected an ErrBadKey, got [%v]", err) } - expectedMessage := "poorly formatted environment: variable 'f ' has white spaces" + expectedMessage := "poorly formatted environment: variable 'f ' contains whitespaces" if err.Error() != expectedMessage { t.Fatalf("Expected [%v], got [%v]", expectedMessage, err.Error()) } @@ -134,7 +134,7 @@ another invalid line` if _, ok := err.(ErrBadKey); !ok { t.Fatalf("Expected an ErrBadKey, got [%v]", err) } - expectedMessage := "poorly formatted environment: variable 'first line' has white spaces" + expectedMessage := "poorly formatted environment: variable 'first line' contains whitespaces" if err.Error() != expectedMessage { t.Fatalf("Expected [%v], got [%v]", expectedMessage, err.Error()) } diff --git a/opts/file.go b/opts/file.go index 96c0c7b84e..2346cc1670 100644 --- a/opts/file.go +++ b/opts/file.go @@ -51,7 +51,7 @@ func parseKeyValueFile(filename string, emptyFn func(string) (string, bool)) ([] // trim the front of a variable, but nothing else variable := strings.TrimLeft(data[0], whiteSpaces) if strings.ContainsAny(variable, whiteSpaces) { - return []string{}, ErrBadKey{fmt.Sprintf("variable '%s' has white spaces", variable)} + return []string{}, ErrBadKey{fmt.Sprintf("variable '%s' contains whitespaces", variable)} } if len(variable) == 0 { return []string{}, ErrBadKey{fmt.Sprintf("no variable name on line '%s'", line)} diff --git a/opts/opts.go b/opts/opts.go index 7e10a0c4f5..765548f6b9 100644 --- a/opts/opts.go +++ b/opts/opts.go @@ -281,10 +281,10 @@ func ValidateLabel(val string) (string, error) { arr := strings.SplitN(val, "=", 2) key := strings.TrimLeft(arr[0], whiteSpaces) if key == "" { - return "", fmt.Errorf("empty label name: '%s'", val) + return "", fmt.Errorf("invalid label '%s': empty name", val) } if strings.ContainsAny(key, whiteSpaces) { - return "", fmt.Errorf("label '%s' has white spaces", key) + return "", fmt.Errorf("label '%s' contains whitespaces", key) } return val, nil } diff --git a/opts/opts_test.go b/opts/opts_test.go index 664c1010d2..4d5ef1749e 100644 --- a/opts/opts_test.go +++ b/opts/opts_test.go @@ -184,17 +184,17 @@ func TestValidateLabel(t *testing.T) { }{ { name: "empty", - expectedErr: `empty label name: ''`, + expectedErr: `invalid label '': empty name`, }, { name: "whitespace only ", value: " ", - expectedErr: `empty label name: ' '`, + expectedErr: `invalid label ' ': empty name`, }, { name: "whitespace around equal-sign", value: " = ", - expectedErr: `empty label name: ' = '`, + expectedErr: `invalid label ' = ': empty name`, }, { name: "leading whitespace", @@ -203,12 +203,12 @@ func TestValidateLabel(t *testing.T) { { name: "whitespaces in key without value", value: "this is a label without value", - expectedErr: `label 'this is a label without value' has white spaces`, + expectedErr: `label 'this is a label without value' contains whitespaces`, }, { name: "whitespaces in key", value: "this is a label=value", - expectedErr: `label 'this is a label' has white spaces`, + expectedErr: `label 'this is a label' contains whitespaces`, }, { name: "whitespaces in value", @@ -229,7 +229,7 @@ func TestValidateLabel(t *testing.T) { { name: "no key", value: "=label", - expectedErr: `empty label name: '=label'`, + expectedErr: `invalid label '=label': empty name`, }, { name: "empty value",