This commit is contained in:
Andrianata Daud 2025-06-04 18:26:24 +02:00 committed by GitHub
commit c06579f1d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 1 deletions

View File

@ -109,6 +109,7 @@ _If you are interested in contributing to kaniko, see
- [Flag `--skip-default-registry-fallback`](#flag---skip-default-registry-fallback)
- [Flag `--reproducible`](#flag---reproducible)
- [Flag `--single-snapshot`](#flag---single-snapshot)
- [Flag `--skip-snapshot`](#flag---skip-snapshot)
- [Flag `--skip-push-permission-check`](#flag---skip-push-permission-check)
- [Flag `--skip-tls-verify`](#flag---skip-tls-verify)
- [Flag `--skip-tls-verify-pull`](#flag---skip-tls-verify-pull)
@ -1078,6 +1079,10 @@ reproducible.
This flag takes a single snapshot of the filesystem at the end of the build, so
only one layer will be appended to the base image.
#### Flag `--skip-snapshot`
This flag allows users to skip all snapshots during the build process. Enabling this flag ensures that no snapshots are taken, potentially speeding up the build process.
#### Flag `--skip-push-permission-check`
Set this flag to skip push permission check. This can be useful to delay Kanikos

View File

@ -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")

View File

@ -77,6 +77,7 @@ type KanikoOptions struct {
CompressionLevel int
ImageFSExtractRetry int
SingleSnapshot bool
SkipSnapshot bool
Reproducible bool
NoPush bool
NoPushCache bool

View File

@ -456,7 +456,12 @@ 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