Skip to content

Commit

Permalink
add flag --no-push (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rauny committed Apr 29, 2021
1 parent df81f82 commit e65b7b3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cmd/kaniko-docker/main.go
Expand Up @@ -127,6 +127,11 @@ func main() {
Usage: "Artifact file location that will be generated by the plugin. This file will include information of docker images that are uploaded by the plugin.",
EnvVar: "PLUGIN_ARTIFACT_FILE",
},
cli.BoolFlag{
Name: "no-push",
Usage: "Set this flag if you only want to build the image, without pushing to a registry",
EnvVar: "PLUGIN_NO_PUSH",
},
}

if err := app.Run(os.Args); err != nil {
Expand Down Expand Up @@ -155,6 +160,7 @@ func run(c *cli.Context) error {
CacheRepo: c.String("cache-repo"),
CacheTTL: c.Int("cache-ttl"),
DigestFile: defaultDigestFile,
NoPush: c.Bool("no-push"),
},
Artifact: kaniko.Artifact{
Tags: c.StringSlice("tags"),
Expand Down
6 changes: 6 additions & 0 deletions cmd/kaniko-ecr/main.go
Expand Up @@ -117,6 +117,11 @@ func main() {
Usage: "Artifact file location that will be generated by the plugin. This file will include information of docker images that are uploaded by the plugin.",
EnvVar: "PLUGIN_ARTIFACT_FILE",
},
cli.BoolFlag{
Name: "no-push",
Usage: "Set this flag if you only want to build the image, without pushing to a registry",
EnvVar: "PLUGIN_NO_PUSH",
},
}

if err := app.Run(os.Args); err != nil {
Expand Down Expand Up @@ -144,6 +149,7 @@ func run(c *cli.Context) error {
CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")),
CacheTTL: c.Int("cache-ttl"),
DigestFile: defaultDigestFile,
NoPush: c.Bool("no-push"),
},
Artifact: kaniko.Artifact{
Tags: c.StringSlice("tags"),
Expand Down
6 changes: 6 additions & 0 deletions cmd/kaniko-gcr/main.go
Expand Up @@ -113,6 +113,11 @@ func main() {
Usage: "Artifact file location that will be generated by the plugin. This file will include information of docker images that are uploaded by the plugin.",
EnvVar: "PLUGIN_ARTIFACT_FILE",
},
cli.BoolFlag{
Name: "no-push",
Usage: "Set this flag if you only want to build the image, without pushing to a registry",
EnvVar: "PLUGIN_NO_PUSH",
},
}

if err := app.Run(os.Args); err != nil {
Expand Down Expand Up @@ -144,6 +149,7 @@ func run(c *cli.Context) error {
CacheRepo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("cache-repo")),
CacheTTL: c.Int("cache-ttl"),
DigestFile: defaultDigestFile,
NoPush: c.Bool("no-push"),
},
Artifact: kaniko.Artifact{
Tags: c.StringSlice("tags"),
Expand Down
6 changes: 5 additions & 1 deletion kaniko.go
Expand Up @@ -26,6 +26,7 @@ type (
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
}
// Artifact defines content of artifact file
Artifact struct {
Expand All @@ -34,7 +35,6 @@ type (
Registry string // Docker artifact registry
RegistryType artifact.RegistryTypeEnum // Rocker artifact registry type
ArtifactFile string // Artifact file location

}

// Plugin defines the Docker plugin parameters.
Expand Down Expand Up @@ -100,6 +100,10 @@ func (p Plugin) Exec() error {
cmdArgs = append(cmdArgs, fmt.Sprintf("--digest-file=%s", p.Build.DigestFile))
}

if p.Build.NoPush {
cmdArgs = append(cmdArgs, fmt.Sprintf("--no-push"))
}

cmd := exec.Command("/kaniko/executor", cmdArgs...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down

0 comments on commit e65b7b3

Please sign in to comment.