Compare commits

...

4 Commits

Author SHA1 Message Date
Shubham Agrawal c090f1bc1e fix formatting 2021-08-18 23:45:51 +05:30
Shubham Agrawal 1a559b8237 fixed formatting 2021-08-18 23:32:14 +05:30
Shubham Agrawal cf4b6443df Add verbosity as params 2021-08-18 23:27:43 +05:30
Rauny e65b7b3ada add flag --no-push (#21) 2021-04-29 20:53:43 +05:30
4 changed files with 49 additions and 4 deletions
+12
View File
@@ -127,6 +127,16 @@ 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",
},
cli.StringFlag{
Name: "verbosity",
Usage: "Set this flag with value as oneof <panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.",
EnvVar: "PLUGIN_VERBOSITY",
},
}
if err := app.Run(os.Args); err != nil {
@@ -155,6 +165,8 @@ func run(c *cli.Context) error {
CacheRepo: c.String("cache-repo"),
CacheTTL: c.Int("cache-ttl"),
DigestFile: defaultDigestFile,
NoPush: c.Bool("no-push"),
Verbosity: c.String("verbosity"),
},
Artifact: kaniko.Artifact{
Tags: c.StringSlice("tags"),
+12
View File
@@ -117,6 +117,16 @@ 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",
},
cli.StringFlag{
Name: "verbosity",
Usage: "Set this flag with value as oneof <panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.",
EnvVar: "PLUGIN_VERBOSITY",
},
}
if err := app.Run(os.Args); err != nil {
@@ -144,6 +154,8 @@ 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"),
Verbosity: c.String("verbosity"),
},
Artifact: kaniko.Artifact{
Tags: c.StringSlice("tags"),
+12
View File
@@ -113,6 +113,16 @@ 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",
},
cli.StringFlag{
Name: "verbosity",
Usage: "Set this flag as --verbosity=<panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.",
EnvVar: "PLUGIN_VERBOSITY",
},
}
if err := app.Run(os.Args); err != nil {
@@ -144,6 +154,8 @@ 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"),
Verbosity: c.String("verbosity"),
},
Artifact: kaniko.Artifact{
Tags: c.StringSlice("tags"),
+13 -4
View File
@@ -26,6 +26,8 @@ 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
Verbosity string // Log level
}
// Artifact defines content of artifact file
Artifact struct {
@@ -34,7 +36,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.
@@ -86,10 +87,10 @@ func (p Plugin) Exec() error {
if p.Build.EnableCache == true {
cmdArgs = append(cmdArgs, fmt.Sprintf("--cache=true"))
}
if p.Build.CacheRepo != "" {
cmdArgs = append(cmdArgs, fmt.Sprintf("--cache-repo=%s", p.Build.CacheRepo))
if p.Build.CacheRepo != "" {
cmdArgs = append(cmdArgs, fmt.Sprintf("--cache-repo=%s", p.Build.CacheRepo))
}
}
if p.Build.CacheTTL != 0 {
@@ -100,6 +101,14 @@ 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"))
}
if p.Build.Verbosity != "" {
cmdArgs = append(cmdArgs, fmt.Sprintf("--verbosity=%s", p.Build.Verbosity))
}
cmd := exec.Command("/kaniko/executor", cmdArgs...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr