mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-09 08:46:35 +02:00
add a new method to indicate if the command provides files to snapshot
This commit is contained in:
+12
-9
@@ -347,15 +347,18 @@ func (s *stageBuilder) build() error {
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
if !isCacheCommand() && !initSnapshotTaken {
|
||||
// Take initial snapshot
|
||||
t := timing.Start("Initial FS snapshot")
|
||||
if err := s.snapshotter.Init(); err != nil {
|
||||
return err
|
||||
}()
|
||||
if !initSnapshotTaken && !isCacheCommand && !command.MetadataOnly() {
|
||||
if !command.ProvidesFilesToSnapshot() {
|
||||
// Take initial snapshot if command is not metadata only
|
||||
// and does not return a list of files changed
|
||||
t := timing.Start("Initial FS snapshot")
|
||||
if err := s.snapshotter.Init(); err != nil {
|
||||
return err
|
||||
}
|
||||
timing.DefaultRun.Stop(t)
|
||||
initSnapshotTaken = true
|
||||
}
|
||||
timing.DefaultRun.Stop(t)
|
||||
initSnapshotTaken = true
|
||||
}
|
||||
|
||||
if err := command.ExecuteCommand(&s.cf.Config, s.args); err != nil {
|
||||
@@ -368,7 +371,7 @@ func (s *stageBuilder) build() error {
|
||||
continue
|
||||
}
|
||||
|
||||
if isCacheCommand() {
|
||||
if isCacheCommand {
|
||||
v := command.(commands.Cached)
|
||||
layer := v.Layer()
|
||||
if err := s.saveLayerToImage(layer, command.String()); err != nil {
|
||||
|
||||
@@ -55,6 +55,9 @@ func (m MockDockerCommand) String() string {
|
||||
func (m MockDockerCommand) FilesToSnapshot() []string {
|
||||
return []string{"meow-snapshot-no-cache"}
|
||||
}
|
||||
func (m MockDockerCommand) ProvidesFilesToSnapshot() bool {
|
||||
return true
|
||||
}
|
||||
func (m MockDockerCommand) CacheCommand(image v1.Image) commands.DockerCommand {
|
||||
return m.cacheCommand
|
||||
}
|
||||
@@ -84,6 +87,9 @@ func (m MockCachedDockerCommand) String() string {
|
||||
func (m MockCachedDockerCommand) FilesToSnapshot() []string {
|
||||
return []string{"meow-snapshot"}
|
||||
}
|
||||
func (m MockCachedDockerCommand) ProvidesFilesToSnapshot() bool {
|
||||
return true
|
||||
}
|
||||
func (m MockCachedDockerCommand) CacheCommand(image v1.Image) commands.DockerCommand {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user