Skip to content

Commit

Permalink
test: retrofit tests for new validation
Browse files Browse the repository at this point in the history
Accoring to new validation in ADD and COPY if there are multiple sources
then destination must specify that it is a directory

Signed-off-by: Aditya R <[email protected]>
  • Loading branch information
flouthoc committed Jan 26, 2023
1 parent 0b4590c commit 33bcb72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions add.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@ func validateSourceAndDest(destination string, sources []string) error {
// filesystem, optionally extracting contents of local files that look like
// non-empty archives.
func (b *Builder) Add(destination string, extract bool, options AddAndCopyOptions, sources ...string) error {
if err := validateSourceAndDest(destination, sources); err != nil {
return err
}
mountPoint, err := b.Mount(b.MountLabel)
if err != nil {
return err
Expand Down Expand Up @@ -279,6 +276,9 @@ func (b *Builder) Add(destination string, extract bool, options AddAndCopyOption
return fmt.Errorf("checking on sources under %q: %w", contextDir, err)
}
}
if err := validateSourceAndDest(destination, localSources); err != nil {
return err
}
numLocalSourceItems := 0
for _, localSourceStat := range localSourceStats {
if localSourceStat.Error != "" {
Expand Down
2 changes: 1 addition & 1 deletion tests/bud/copy-globs/Containerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM scratch
# *txt exists so should succeed
COPY *.txt /testdir
COPY *.txt /testdir/

0 comments on commit 33bcb72

Please sign in to comment.