Skip to content

Commit 47ec27c

Browse files
committed
parser: avoid creating temp error string
This error is always ignored by caller and only used as nil check. Could keep previous output and move Printf to Error() method but not needed as nothing is actually reading the original input. Signed-off-by: Tonis Tiigi <[email protected]>
1 parent 0f49905 commit 47ec27c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

frontend/dockerfile/parser/line_parsers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
var (
1919
errDockerfileNotStringArray = errors.New("when using JSON array syntax, arrays must be comprised of strings only")
20+
errDockerfileNotJSONArray = errors.New("not a JSON array")
2021
)
2122

2223
const (
@@ -277,7 +278,7 @@ func parseString(rest string, d *directives) (*Node, map[string]bool, error) {
277278
func parseJSON(rest string) (*Node, map[string]bool, error) {
278279
rest = strings.TrimLeftFunc(rest, unicode.IsSpace)
279280
if !strings.HasPrefix(rest, "[") {
280-
return nil, nil, errors.Errorf("Error parsing %q as a JSON array", rest)
281+
return nil, nil, errDockerfileNotJSONArray
281282
}
282283

283284
var myJSON []interface{}

0 commit comments

Comments
 (0)