Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for kaniko executor single-snapshot flag #90

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/kaniko-acr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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")),
Expand Down
6 changes: 6 additions & 0 deletions cmd/kaniko-docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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")),
Expand Down
6 changes: 6 additions & 0 deletions cmd/kaniko-ecr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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")),
Expand Down
6 changes: 6 additions & 0 deletions cmd/kaniko-gar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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")),
Expand Down
6 changes: 6 additions & 0 deletions cmd/kaniko-gcr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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")),
Expand Down
7 changes: 6 additions & 1 deletion kaniko.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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
Expand Down