add a new method to indicate if the command provides files to snapshot

This commit is contained in:
Tejal Desai
2020-05-01 15:50:46 -07:00
parent 2e1ca5f19d
commit 32e3336d4c
9 changed files with 61 additions and 10 deletions
+4
View File
@@ -116,6 +116,10 @@ func (a *AddCommand) FilesToSnapshot() []string {
return a.snapshotFiles
}
func (a *AddCommand) ProvidesFilesToSnapshot() bool {
return true
}
// String returns some information about the command for the image config
func (a *AddCommand) String() string {
return a.cmd.String()
+4
View File
@@ -32,6 +32,10 @@ func (b *BaseCommand) FilesToSnapshot() []string {
return []string{}
}
func (b *BaseCommand) ProvidesFilesToSnapshot() bool {
return false
}
func (b *BaseCommand) FilesUsedFromContext(_ *v1.Config, _ *dockerfile.BuildArgs) ([]string, error) {
return []string{}, nil
}
+4
View File
@@ -37,6 +37,10 @@ type DockerCommand interface {
// A list of files to snapshot, empty for metadata commands or nil if we don't know
FilesToSnapshot() []string
// ProvidesFileToSnapshot is true for all metadata commands and commands which know
// list of files changed. False for Run command.
ProvidesFilesToSnapshot() bool
// Return a cache-aware implementation of this command, if it exists.
CacheCommand(v1.Image) DockerCommand
+12
View File
@@ -138,6 +138,10 @@ func (c *CopyCommand) MetadataOnly() bool {
return false
}
func (c *CopyCommand) ProvidesFilesToSnapshot() bool {
return true
}
func (c *CopyCommand) RequiresUnpackedFS() bool {
return true
}
@@ -210,6 +214,14 @@ func (cr *CachingCopyCommand) FilesToSnapshot() []string {
return f
}
func (cr *CachingCopyCommand) MetadataOnly() bool {
return false
}
func (cr *CachingCopyCommand) ProvidesFilesToSnapshot() bool {
return true
}
func (cr *CachingCopyCommand) String() string {
if cr.cmd == nil {
return "nil command"
+12
View File
@@ -151,6 +151,10 @@ func (r *RunCommand) FilesToSnapshot() []string {
return nil
}
func (r *RunCommand) ProvidesFilesToSnapshot() bool {
return false
}
// CacheCommand returns true since this command should be cached
func (r *RunCommand) CacheCommand(img v1.Image) DockerCommand {
@@ -227,3 +231,11 @@ func (cr *CachingRunCommand) String() string {
}
return cr.cmd.String()
}
func (cr *CachingRunCommand) MetadataOnly() bool {
return false
}
func (cr *CachingRunCommand) RequiresUnpackedFS() bool {
return true
}
+4
View File
@@ -75,3 +75,7 @@ func (w *WorkdirCommand) String() string {
func (w *WorkdirCommand) MetadataOnly() bool {
return false
}
func (w *WorkdirCommand) ProvidesFilesToSnapshot() bool {
return true
}