diff --git a/cmd/executor/cmd/root.go b/cmd/executor/cmd/root.go index 7f0339c5d..a3281ad9e 100644 --- a/cmd/executor/cmd/root.go +++ b/cmd/executor/cmd/root.go @@ -244,6 +244,7 @@ func addKanikoOptionsFlags() { RootCmd.PersistentFlags().StringVarP(&opts.KanikoDir, "kaniko-dir", "", constants.DefaultKanikoPath, "Path to the kaniko directory, this takes precedence over the KANIKO_DIR environment variable.") RootCmd.PersistentFlags().StringVarP(&opts.TarPath, "tar-path", "", "", "Path to save the image in as a tarball instead of pushing") RootCmd.PersistentFlags().BoolVarP(&opts.SingleSnapshot, "single-snapshot", "", false, "Take a single snapshot at the end of the build.") + RootCmd.PersistentFlags().BoolVarP(&opts.SkipSnapshot, "skip-snapshot", "", false, "Skip all snapshots for the duration of the build.") RootCmd.PersistentFlags().BoolVarP(&opts.Reproducible, "reproducible", "", false, "Strip timestamps out of the image to make it reproducible") RootCmd.PersistentFlags().StringVarP(&opts.Target, "target", "", "", "Set the target build stage to build") RootCmd.PersistentFlags().BoolVarP(&opts.NoPush, "no-push", "", false, "Do not push the image to the registry") diff --git a/pkg/config/options.go b/pkg/config/options.go index dbc1e0297..0d684c6fd 100644 --- a/pkg/config/options.go +++ b/pkg/config/options.go @@ -77,6 +77,7 @@ type KanikoOptions struct { CompressionLevel int ImageFSExtractRetry int SingleSnapshot bool + SkipSnapshot bool Reproducible bool NoPush bool NoPushCache bool diff --git a/pkg/executor/build.go b/pkg/executor/build.go index 73b2f0df2..5c1236494 100644 --- a/pkg/executor/build.go +++ b/pkg/executor/build.go @@ -457,6 +457,11 @@ func (s *stageBuilder) takeSnapshot(files []string, shdDelete bool) (string, err func (s *stageBuilder) shouldTakeSnapshot(index int, isMetadatCmd bool) bool { isLastCommand := index == len(s.cmds)-1 + // Skip snapshot entirely with skip snapshot mode on. + if s.opts.SkipSnapshot { + return false + } + // We only snapshot the very end with single snapshot mode on. if s.opts.SingleSnapshot { return isLastCommand