diff --git a/cmd/kaniko-acr/main.go b/cmd/kaniko-acr/main.go index ff60c55..08db846 100644 --- a/cmd/kaniko-acr/main.go +++ b/cmd/kaniko-acr/main.go @@ -151,6 +151,11 @@ func main() { Usage: "Azure Client Id", EnvVar: "CLIENT_ID", }, + cli.StringFlag{ + Name: "single-snapshot", + Usage: "Takes a single snapshot of the filesystem at the end of the build, only that will be appended to the base image", + EnvVar: "PLUGIN_SINGLE_SNAPSHOT", + }, cli.StringFlag{ Name: "snapshot-mode", Usage: "Specify one of full, redo or time as snapshot mode", @@ -245,6 +250,7 @@ func run(c *cli.Context) error { Repo: c.String("repo"), Mirrors: c.StringSlice("registry-mirrors"), Labels: c.StringSlice("custom-labels"), + SingleSnapshot: c.Bool("single-snapshot"), SnapshotMode: c.String("snapshot-mode"), EnableCache: c.Bool("enable-cache"), CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")), diff --git a/cmd/kaniko-docker/main.go b/cmd/kaniko-docker/main.go index a0511da..022ef93 100644 --- a/cmd/kaniko-docker/main.go +++ b/cmd/kaniko-docker/main.go @@ -146,6 +146,11 @@ func main() { Usage: "Skip registry tls verify", EnvVar: "PLUGIN_SKIP_TLS_VERIFY", }, + cli.StringFlag{ + Name: "single-snapshot", + Usage: "Takes a single snapshot of the filesystem at the end of the build, only that will be appended to the base image", + EnvVar: "PLUGIN_SINGLE_SNAPSHOT", + }, cli.StringFlag{ Name: "snapshot-mode", Usage: "Specify one of full, redo or time as snapshot mode", @@ -241,6 +246,7 @@ func run(c *cli.Context) error { Mirrors: c.StringSlice("registry-mirrors"), Labels: c.StringSlice("custom-labels"), SkipTlsVerify: c.Bool("skip-tls-verify"), + SingleSnapshot: c.Bool("single-snapshot"), SnapshotMode: c.String("snapshot-mode"), EnableCache: c.Bool("enable-cache"), CacheRepo: buildRepo(c.String("registry"), c.String("cache-repo"), c.Bool("expand-repo")), diff --git a/cmd/kaniko-ecr/main.go b/cmd/kaniko-ecr/main.go index 1652369..06311d1 100644 --- a/cmd/kaniko-ecr/main.go +++ b/cmd/kaniko-ecr/main.go @@ -169,6 +169,11 @@ func main() { Usage: "ECR secret key", EnvVar: "PLUGIN_SECRET_KEY", }, + cli.StringFlag{ + Name: "single-snapshot", + Usage: "Takes a single snapshot of the filesystem at the end of the build, only that will be appended to the base image", + EnvVar: "PLUGIN_SINGLE_SNAPSHOT", + }, cli.StringFlag{ Name: "assume-role", Usage: "Assume a role", @@ -316,6 +321,7 @@ func run(c *cli.Context) error { Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")), Mirrors: c.StringSlice("registry-mirrors"), Labels: c.StringSlice("custom-labels"), + SingleSnapshot: c.Bool("single-snapshot"), SnapshotMode: c.String("snapshot-mode"), EnableCache: c.Bool("enable-cache"), CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")), diff --git a/cmd/kaniko-gar/main.go b/cmd/kaniko-gar/main.go index 93edd84..382c502 100644 --- a/cmd/kaniko-gar/main.go +++ b/cmd/kaniko-gar/main.go @@ -119,6 +119,11 @@ func main() { Usage: "docker username", EnvVar: "PLUGIN_JSON_KEY", }, + cli.StringFlag{ + Name: "single-snapshot", + Usage: "Takes a single snapshot of the filesystem at the end of the build, only that will be appended to the base image", + EnvVar: "PLUGIN_SINGLE_SNAPSHOT", + }, cli.StringFlag{ Name: "snapshot-mode", Usage: "Specify one of full, redo or time as snapshot mode", @@ -199,6 +204,7 @@ func run(c *cli.Context) error { Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")), Mirrors: c.StringSlice("registry-mirrors"), Labels: c.StringSlice("custom-labels"), + SingleSnapshot: c.Bool("single-snapshot"), SnapshotMode: c.String("snapshot-mode"), EnableCache: c.Bool("enable-cache"), CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")), diff --git a/cmd/kaniko-gcr/main.go b/cmd/kaniko-gcr/main.go index 74bb2e5..9a14ea0 100644 --- a/cmd/kaniko-gcr/main.go +++ b/cmd/kaniko-gcr/main.go @@ -120,6 +120,11 @@ func main() { Usage: "docker username", EnvVar: "PLUGIN_JSON_KEY", }, + cli.StringFlag{ + Name: "single-snapshot", + Usage: "Takes a single snapshot of the filesystem at the end of the build, only that will be appended to the base image", + EnvVar: "PLUGIN_SINGLE_SNAPSHOT", + }, cli.StringFlag{ Name: "snapshot-mode", Usage: "Specify one of full, redo or time as snapshot mode", @@ -200,6 +205,7 @@ func run(c *cli.Context) error { Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")), Mirrors: c.StringSlice("registry-mirrors"), Labels: c.StringSlice("custom-labels"), + SingleSnapshot: c.Bool("single-snapshot"), SnapshotMode: c.String("snapshot-mode"), EnableCache: c.Bool("enable-cache"), CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")), diff --git a/kaniko.go b/kaniko.go index 62d324c..3a0ae5a 100644 --- a/kaniko.go +++ b/kaniko.go @@ -30,6 +30,7 @@ type ( Mirrors []string // Docker repository mirrors Labels []string // Label map SkipTlsVerify bool // Docker skip tls certificate verify for registry + SingleSnapshot bool // Kaniko single snapshot mode SnapshotMode string // Kaniko snapshot mode EnableCache bool // Whether to enable kaniko cache CacheRepo string // Remote repository that will be used to store cached layers @@ -189,6 +190,10 @@ func (p Plugin) Exec() error { cmdArgs = append(cmdArgs, fmt.Sprintf("--snapshotMode=%s", p.Build.SnapshotMode)) } + if p.Build.SingleSnapshot { + cmdArgs = append(cmdArgs, "--single-snapshot=true") + } + if p.Build.EnableCache { cmdArgs = append(cmdArgs, "--cache=true") @@ -224,7 +229,7 @@ func (p Plugin) Exec() error { if p.Build.TarPath != "" { cmdArgs = append(cmdArgs, fmt.Sprintf("--tar-path=%s", p.Build.TarPath)) } - + cmd := exec.Command("/kaniko/executor", cmdArgs...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr