Fix integration tests

This commit is contained in:
Priya Wadhwa
2018-10-30 15:59:50 -07:00
parent 3fc43f4c73
commit cb0a5e0a18
2 changed files with 16 additions and 4 deletions
+5 -1
View File
@@ -63,7 +63,7 @@ var RootCmd = &cobra.Command{
return errors.Wrap(err, "error resolving source context")
}
if err := removeIgnoredFiles(); err != nil {
return errors.Wrap(err, "error removing ignored files from build context")
return errors.Wrap(err, "error removing .dockerignore files from build context")
}
return resolveDockerfilePath()
},
@@ -198,9 +198,11 @@ func removeIgnoredFiles() error {
for r, i := range ignore {
ignore[r] = filepath.Clean(filepath.Join(opts.SrcContext, i))
}
// first, remove all files in .dockerignore
err = filepath.Walk(opts.SrcContext, func(path string, fi os.FileInfo, _ error) error {
if ignoreFile(path, ignore) {
if err := os.RemoveAll(path); err != nil {
// don't return error, because this path could have been removed already
logrus.Debugf("error removing %s from buildcontext", path)
}
}
@@ -209,10 +211,12 @@ func removeIgnoredFiles() error {
if err != nil {
return err
}
// then, remove .dockerignore
path := filepath.Join(opts.SrcContext, ".dockerignore")
return os.Remove(path)
}
// ignoreFile returns true if the path matches any of the paths in ignore
func ignoreFile(path string, ignore []string) bool {
for _, i := range ignore {
matched, err := filepath.Match(i, path)