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

added the upstream option for the single snapshot mode #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
40 changes: 23 additions & 17 deletions cmd/kaniko-docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra space after that in all the 3 files.

EnvVar: "PLUGIN_SINGLE_SNAPSHOT",
},
cli.StringFlag{
Name: "snapshot-mode",
Usage: "Specify one of full, redo or time as snapshot mode",
Expand Down Expand Up @@ -170,23 +175,24 @@ func run(c *cli.Context) error {

plugin := kaniko.Plugin{
Build: kaniko.Build{
Dockerfile: c.String("dockerfile"),
Context: c.String("context"),
Tags: c.StringSlice("tags"),
AutoTag: c.Bool("auto_tag"),
Args: c.StringSlice("args"),
Target: c.String("target"),
Repo: c.String("repo"),
Labels: c.StringSlice("custom-labels"),
SkipTlsVerify: c.Bool("skip-tls-verify"),
SnapshotMode: c.String("snapshot-mode"),
EnableCache: c.Bool("enable-cache"),
CacheRepo: c.String("cache-repo"),
CacheTTL: c.Int("cache-ttl"),
DigestFile: defaultDigestFile,
NoPush: noPush,
Verbosity: c.String("verbosity"),
Platform: c.String("platform"),
Dockerfile: c.String("dockerfile"),
Context: c.String("context"),
Tags: c.StringSlice("tags"),
AutoTag: c.Bool("auto_tag"),
Args: c.StringSlice("args"),
Target: c.String("target"),
Repo: c.String("repo"),
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: c.String("cache-repo"),
CacheTTL: c.Int("cache-ttl"),
DigestFile: defaultDigestFile,
NoPush: noPush,
Verbosity: c.String("verbosity"),
Platform: c.String("platform"),
},
Artifact: kaniko.Artifact{
Tags: c.StringSlice("tags"),
Expand Down
38 changes: 22 additions & 16 deletions cmd/kaniko-ecr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,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: "snapshot-mode",
Usage: "Specify one of full, redo or time as snapshot mode",
Expand Down Expand Up @@ -242,22 +247,23 @@ func run(c *cli.Context) error {

plugin := kaniko.Plugin{
Build: kaniko.Build{
Dockerfile: c.String("dockerfile"),
Context: c.String("context"),
Tags: c.StringSlice("tags"),
AutoTag: c.Bool("auto_tag"),
Args: c.StringSlice("args"),
Target: c.String("target"),
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
Labels: c.StringSlice("custom-labels"),
SnapshotMode: c.String("snapshot-mode"),
EnableCache: c.Bool("enable-cache"),
CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")),
CacheTTL: c.Int("cache-ttl"),
DigestFile: defaultDigestFile,
NoPush: noPush,
Verbosity: c.String("verbosity"),
Platform: c.String("platform"),
Dockerfile: c.String("dockerfile"),
Context: c.String("context"),
Tags: c.StringSlice("tags"),
AutoTag: c.Bool("auto_tag"),
Args: c.StringSlice("args"),
Target: c.String("target"),
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
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")),
CacheTTL: c.Int("cache-ttl"),
DigestFile: defaultDigestFile,
NoPush: noPush,
Verbosity: c.String("verbosity"),
Platform: c.String("platform"),
},
Artifact: kaniko.Artifact{
Tags: c.StringSlice("tags"),
Expand Down
38 changes: 22 additions & 16 deletions cmd/kaniko-gcr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,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 @@ -157,22 +162,23 @@ func run(c *cli.Context) error {

plugin := kaniko.Plugin{
Build: kaniko.Build{
Dockerfile: c.String("dockerfile"),
Context: c.String("context"),
Tags: c.StringSlice("tags"),
AutoTag: c.Bool("auto_tag"),
Args: c.StringSlice("args"),
Target: c.String("target"),
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
Labels: c.StringSlice("custom-labels"),
SnapshotMode: c.String("snapshot-mode"),
EnableCache: c.Bool("enable-cache"),
CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")),
CacheTTL: c.Int("cache-ttl"),
DigestFile: defaultDigestFile,
NoPush: noPush,
Verbosity: c.String("verbosity"),
Platform: c.String("platform"),
Dockerfile: c.String("dockerfile"),
Context: c.String("context"),
Tags: c.StringSlice("tags"),
AutoTag: c.Bool("auto_tag"),
Args: c.StringSlice("args"),
Target: c.String("target"),
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
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")),
CacheTTL: c.Int("cache-ttl"),
DigestFile: defaultDigestFile,
NoPush: noPush,
Verbosity: c.String("verbosity"),
Platform: c.String("platform"),
},
Artifact: kaniko.Artifact{
Tags: c.StringSlice("tags"),
Expand Down
39 changes: 22 additions & 17 deletions kaniko.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@ import (
type (
// Build defines Docker build parameters.
Build struct {
Dockerfile string // Docker build Dockerfile
Context string // Docker build context
Tags []string // Docker build tags
AutoTag bool // Set this to create semver-tagged labels
Args []string // Docker build args
Target string // Docker build target
Repo string // Docker build repository
Labels []string // Label map
SkipTlsVerify bool // Docker skip tls certificate verify for registry
SnapshotMode string // Kaniko snapshot mode
EnableCache bool // Whether to enable kaniko cache
CacheRepo string // Remote repository that will be used to store cached layers
CacheTTL int // Cache timeout in hours
DigestFile string // Digest file location
NoPush bool // Set this flag if you only want to build the image, without pushing to a registry
Verbosity string // Log level
Platform string // Allows to build with another default platform than the host, similarly to docker build --platform
Dockerfile string // Docker build Dockerfile
Context string // Docker build context
Tags []string // Docker build tags
AutoTag bool // Set this to create semver-tagged labels
Args []string // Docker build args
Target string // Docker build target
Repo string // Docker build repository
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
CacheTTL int // Cache timeout in hours
DigestFile string // Digest file location
NoPush bool // Set this flag if you only want to build the image, without pushing to a registry
Verbosity string // Log level
Platform string // Allows to build with another default platform than the host, similarly to docker build --platform
}

// Artifact defines content of artifact file
Expand Down Expand Up @@ -134,6 +135,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