Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Commit

Permalink
trim quotes from copy from/to paths (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
preslavmihaylov authored and Yiran Wang committed Oct 23, 2019
1 parent 2fff0eb commit 1bacf2a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/builder/step/add_copy_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ func newAddCopyStep(
directive Directive, args, chown, fromStage string,
fromPaths []string, toPath string, commit bool) (*addCopyStep, error) {

toPath = strings.Trim(toPath, "\"'")
for i := range fromPaths {
fromPaths[i] = strings.Trim(fromPaths[i], "\"'")
}

if len(fromPaths) > 1 && !(strings.HasSuffix(toPath, "/") || toPath == "." || toPath == "..") {
return nil, fmt.Errorf("copying multiple source files, target must be a directory ending in \"/\"")
}
Expand Down
10 changes: 10 additions & 0 deletions lib/builder/step/add_copy_step_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,13 @@ func TestContextDirs(t *testing.T) {
require.Equal("stage", stage)
require.Len(paths, 1)
}

func TestTrimmingPaths(t *testing.T) {
require := require.New(t)

ac, err := newAddCopyStep(Copy, "", "", "", []string{"\"/from/path\""}, "\"/to/path\"", false)
require.NoError(err)

require.Equal("/from/path", ac.fromPaths[0])
require.Equal("/to/path", ac.toPath)
}

0 comments on commit 1bacf2a

Please sign in to comment.