Fix integration tests
This commit is contained in:
parent
3fc43f4c73
commit
cb0a5e0a18
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ const (
|
|||
buildContextPath = "/workspace"
|
||||
cacheDir = "/workspace/cache"
|
||||
baseImageToCache = "gcr.io/google-appengine/debian9@sha256:1d6a9a6d106bd795098f60f4abb7083626354fa6735e81743c7f8cfca11259f0"
|
||||
testDirPath = "test/dir/path"
|
||||
testDirPath = "context/test"
|
||||
)
|
||||
|
||||
// Arguments to build Dockerfiles with, used for both docker and kaniko builds
|
||||
|
|
@ -55,7 +55,7 @@ var argsMap = map[string][]string{
|
|||
"Dockerfile_test_multistage": {"file=/foo2"},
|
||||
}
|
||||
|
||||
var filesToIgnore = []string{"test/*"}
|
||||
var filesToIgnore = []string{"context/test/*"}
|
||||
|
||||
// Arguments to build Dockerfiles with when building with docker
|
||||
var additionalDockerFlagsMap = map[string][]string{
|
||||
|
|
@ -271,7 +271,15 @@ func (d *DockerFileBuilder) buildCachedImages(imageRepo, cacheRepo, dockerfilesP
|
|||
}
|
||||
|
||||
func setupTestDir() error {
|
||||
return os.MkdirAll(testDirPath, 0644)
|
||||
if err := os.MkdirAll(testDirPath, 0750); err != nil {
|
||||
return err
|
||||
}
|
||||
p := filepath.Join(testDirPath, "foo")
|
||||
f, err := os.Create(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return f.Close()
|
||||
}
|
||||
|
||||
func generateDockerIgnore() error {
|
||||
|
|
|
|||
Loading…
Reference in New Issue