Merge pull request #470 from priyawadhwa/remove-dockerignore
Remove support for .dockerignore
This commit is contained in:
		
						commit
						d1a7d5c97f
					
				|  | @ -25,10 +25,8 @@ import ( | |||
| 	"github.com/GoogleContainerTools/kaniko/pkg/buildcontext" | ||||
| 	"github.com/GoogleContainerTools/kaniko/pkg/config" | ||||
| 	"github.com/GoogleContainerTools/kaniko/pkg/constants" | ||||
| 	"github.com/GoogleContainerTools/kaniko/pkg/dockerfile" | ||||
| 	"github.com/GoogleContainerTools/kaniko/pkg/executor" | ||||
| 	"github.com/GoogleContainerTools/kaniko/pkg/util" | ||||
| 	"github.com/docker/docker/pkg/fileutils" | ||||
| 	"github.com/genuinetools/amicontained/container" | ||||
| 	"github.com/pkg/errors" | ||||
| 	"github.com/sirupsen/logrus" | ||||
|  | @ -67,7 +65,7 @@ var RootCmd = &cobra.Command{ | |||
| 		if err := resolveDockerfilePath(); err != nil { | ||||
| 			return errors.Wrap(err, "error resolving dockerfile path") | ||||
| 		} | ||||
| 		return removeIgnoredFiles() | ||||
| 		return nil | ||||
| 	}, | ||||
| 	Run: func(cmd *cobra.Command, args []string) { | ||||
| 		if !checkContained() { | ||||
|  | @ -200,29 +198,6 @@ func resolveSourceContext() error { | |||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func removeIgnoredFiles() error { | ||||
| 	if !dockerfile.DockerignoreExists(opts) { | ||||
| 		return nil | ||||
| 	} | ||||
| 	ignore, err := dockerfile.ParseDockerignore(opts) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	logrus.Infof("Removing ignored files from build context: %s", ignore) | ||||
| 	files, err := util.RelativeFiles("", opts.SrcContext) | ||||
| 	if err != nil { | ||||
| 		return errors.Wrap(err, "getting all files in src context") | ||||
| 	} | ||||
| 	for _, f := range files { | ||||
| 		if rm, _ := fileutils.Matches(f, ignore); rm { | ||||
| 			if err := os.RemoveAll(f); err != nil { | ||||
| 				logrus.Errorf("Error removing %s from build context", f) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func exit(err error) { | ||||
| 	fmt.Println(err) | ||||
| 	os.Exit(1) | ||||
|  |  | |||
|  | @ -276,6 +276,9 @@ func TestCache(t *testing.T) { | |||
| } | ||||
| 
 | ||||
| func TestDockerignore(t *testing.T) { | ||||
| 	// TODO (priyawadhwa@): remove this once .dockerignore is implemented correctly
 | ||||
| 	t.Skip() | ||||
| 
 | ||||
| 	t.Run(fmt.Sprintf("test_%s", ignoreDockerfile), func(t *testing.T) { | ||||
| 		if err := setupIgnoreTestDir(); err != nil { | ||||
| 			t.Fatalf("error setting up ignore test dir: %v", err) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue