Skip to content

Commit

Permalink
frontend/dockerfile/dockerignore: remove hard-coded filename from error
Browse files Browse the repository at this point in the history
While this function would usually be used for read a `.dockerignore` file,
it accepts a Reader and can also be used to handle ignore patterns from
other files (e.g. `Dockerfile.dockerignore`) or other sources. The error
was also wrapped multiple times in some code-paths, which could lead to
an error being formatted as:

    failed to parse dockerignore: error reading .dockerignore: <some error>

Let's remove mention of the `.dockerignore` filename from the error, and
leave it to the caller to include the filename.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Jul 25, 2023
1 parent 102563d commit 971814f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions frontend/dockerfile/dockerignore/dockerignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"io"
"path/filepath"
"strings"

"github.com/pkg/errors"
)

// ReadAll reads an ignore file from a reader and returns the list of file
Expand Down Expand Up @@ -69,7 +67,7 @@ func ReadAll(reader io.Reader) ([]string, error) {
excludes = append(excludes, pattern)
}
if err := scanner.Err(); err != nil {
return nil, errors.Wrap(err, "error reading .dockerignore")
return nil, err
}
return excludes, nil
}
2 changes: 1 addition & 1 deletion frontend/dockerui/namedcontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (bc *Client) namedContextRecursive(ctx context.Context, name string, nameWi
if len(dt) != 0 {
excludes, err = dockerignore.ReadAll(bytes.NewBuffer(dt))
if err != nil {
return nil, nil, err
return nil, nil, errors.Wrapf(err, "error parsing %s", DefaultDockerignoreName)
}
}
}
Expand Down

0 comments on commit 971814f

Please sign in to comment.