Add CacheCommand to DockerCommand interface

CacheCommand returns true if the command should be cached. Currently,
it's only true for RUN but can be added to ADD/COPY later on (these are
different since the contents of files for ADD/COPY need to be included
in the cache key generation).

I also changed CreatedBy to String so that we can log each command
before cache extraction or regular execution takes place.
This commit is contained in:
Priya Wadhwa
2018-09-04 13:16:05 -07:00
parent 2e10d2761c
commit 4f3ab61b96
18 changed files with 129 additions and 116 deletions
+2 -1
View File
@@ -85,6 +85,7 @@ func DoBuild(opts *options.KanikoOptions) (v1.Image, error) {
if dockerCommand == nil {
continue
}
logrus.Info(dockerCommand.String())
if err := dockerCommand.ExecuteCommand(&imageConfig.Config, buildArgs); err != nil {
return nil, err
}
@@ -138,7 +139,7 @@ func DoBuild(opts *options.KanikoOptions) (v1.Image, error) {
Layer: layer,
History: v1.History{
Author: constants.Author,
CreatedBy: dockerCommand.CreatedBy(),
CreatedBy: dockerCommand.String(),
},
},
)